Skip to content

Tag

Used for marking and selection.

Basic Usage

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

Tag 1Tag 2Tag 3Tag 4Tag 5
Basic Usage

Theme Effects

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

Dark:Tag 1Tag 2Tag 3Tag 4Tag 5
Light:Tag 1Tag 2Tag 3Tag 4Tag 5
Plain:Tag 1Tag 2Tag 3Tag 4Tag 5
Theme Effects

Closable Tags

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

Tag 1Tag 2Tag 3Tag 4Tag 5
Closable Tags

Dynamic Editing

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

Tag 1Tag 2Tag 3
Dynamic Editing

Checkable Tags

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

Tag 1Tag 2Tag 3

Selection Status: [ true, false, false ]

Checkable Tags

Different Sizes

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

LargeDefaultSmallLargeDefaultSmall
Different Sizes

Round Tags

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

Tag 1Tag 2Tag 3Tag 4Tag 5
Round Tags

Custom Colors

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

Custom PurpleCustom OrangeCustom CyanCustom PinkCustom Teal
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.

CompletedIn ProgressWarning InfoTips
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.

Nuxt Auto ImportNuxtVueVite
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-transitionsWhether to disable fade animationsbooleanfalse
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 componentComponent
suffix-iconRight icon componentComponent

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
suffix-iconCustom right icon
close-iconCustom close icon

Theme Variables

VariableDescriptionDefault
--yh-tag-font-sizeFont sizevar(--yh-font-size-xs)
--yh-tag-border-radiusBorder radiusvar(--yh-radius-sm)
--yh-tag-bg-colorBackground color(varies by type)
--yh-tag-border-colorBorder color(varies by type)
--yh-tag-text-colorText color(varies by type)

Released under the MIT License.