Skip to content
Latestv1.0.63

Tag ​

Used for marking and selection.

Basic Usage ​

Use the type property to define the tag's type.

Basic Usage

Theme Effects ​

The Tag component provides three theme effects: dark, light (default), and plain.

Theme Effects

Closable Tags ​

Use the closable property to define a closable tag. Clicking the close button triggers the close event.

Closable Tags

Dynamic Editing ​

Dynamic editing can be implemented by responding to the close event triggered when a tag's close button is clicked.

Dynamic Editing

Checkable Tags ​

Use the checkable property to define a tag that can be selected, paired with v-model:checked.

Checkable Tags

Different Sizes ​

Use the size property to control the tag's dimensions.

Different Sizes

Round Tags ​

Use the round property to make the tag circular/round.

Round Tags

Custom Colors ​

Use the color property to customize the tag's background color.

Custom Colors

Icon Configuration ​

Use the icon property or #icon slot for the left icon, and the suffix-icon property or #suffixIcon slot for the right icon.

Icon Configuration

Usage in Nuxt ​

The Tag component fully supports SSR in Nuxt 3/4. Its lightweight design makes it ideal for status display and categorization in Nuxt projects.

Usage in Nuxt

SSR Considerations:

  • ✅ All types, sizes, and effects generate HTML offline on the server.
  • ✅ Custom colors and rounded corners are supported in SSR.
  • ✅ Icon slots (prefix and suffix) are correctly filled on the server.
  • 💡 Interactions (like closing or editing) become active after client-side hydration.

Ultra Lightweight

The CSS for the Tag component is highly optimized/atomic, adding minimal style overhead to SSR pages, making it an ideal choice for performance-focused Nuxt apps.

API ​

Props ​

NameDescriptionTypeDefault
typeTag type'primary' | 'success' | 'warning' | 'danger' | 'info''primary'
sizeTag size'large' | 'default' | 'small''default'
effectTheme effect'dark' | 'light' | 'plain''light'
closableWhether the tag is closablebooleanfalse
roundWhether the tag has rounded cornersbooleanfalse
colorCustom background colorstring—
hitWhether the tag has a border strokebooleanfalse
disable-transitionsCompatibility prop. The current template and stylesheet do not consume this optionbooleanfalse
checkableWhether the tag is selectablebooleanfalse
checked / v-model:checkedWhether the tag is currently selectedbooleanfalse
editableWhether the tag is editable (double-click to edit)booleanfalse
iconLeft icon. Component values render directly; string values are currently declared but not rendered by the templatestring | Componentundefined
suffix-iconRight icon. Component values render directly; string values are currently declared but not rendered by the templatestring | Componentundefined
theme-overridesComponent-level theme overridesComponentThemeVarsundefined

Events ​

NameDescriptionParameters
clickTriggers when the tag is clicked(event: MouseEvent) => void
closeTriggers when the close button is clicked(event: MouseEvent) => void
update:checkedTriggers when selection status changes(checked: boolean) => void
changeTriggers when selection status changes(checked: boolean) => void
editTriggers when editing is completed(value: string) => void

Slots ​

NameDescription
defaultTag content
iconCustom left icon
suffixIconCustom right icon
closeIconCustom close icon

Theme Variables ​

VariableDescriptionDefault
--yh-tag-bg-colorBackground color(varies by type)
--yh-tag-border-colorBorder color(varies by type)
--yh-tag-text-colorText color(varies by type)
--yh-tag-hover-colorAccent color used by interaction statesvar(--yh-color-primary)

Other size, radius, and typography values still come from shared theme tokens such as --yh-font-size-xs, --yh-radius-sm, and --yh-radius-round.

Type Exports ​

NameDescription
YhTagPropsComponent props type
YhTagEmitsComponent emits type
YhTagSlotsComponent slots type
YhTagTypeTag type union
YhTagSizeTag size union
YhTagEffectTag effect union
YhTagInstanceComponent instance type

Expose ​

This component does not expose public instance methods or properties.

Released under the MIT License.