GitHub
Core
Glass
Brutal
Humanist

Tag

Tags are interactive elements used for filtering, categorization, or selection. They support various leading items like icons, avatars, country flags, colors, and brand icons.

Tag Playground

Tag Playground
Preview
Code
Category Label
Controls
State:
Default
Selected
Disabled
Size:
Default
Small
Leading:
None
Icon
Avatar
Country
Color
Brand
Removable:

Installation

You can add the tag component to your project manually:

1

Install the following dependencies:

npm install class-variance-authority clsx tailwind-merge @phosphor-icons/react @react-aria/focus
2

Copy and paste the following code into your project.

Loading source code...
3

Update the import paths to match your project setup.

Update the import aliases (e.g. @/components, @/utils) in the copied files to match your project's path configuration.

Basic Usage

import { Tag } from '@versaui/ui/components/Tag';

// Default tag
<Tag label="Category" />

// Non-removable tag
<Tag removable={false} label="Permanent" />

Leading Items

Tags support different types of leading visual elements:

// Icon
<Tag leadingItem="icon" label="Filter" />

// Avatar
<Tag leadingItem="avatar" avatarPerson="adam-smith" label="User" />

// Country flag
<Tag leadingItem="country" countryCode="us" label="United States" />

// Color indicator
<Tag leadingItem="color" colorValue="#FF5733" label="Color" />

// Brand icon
<Tag leadingItem="brand" brandPlatform="figma" label="Figma" />

States

// Selected
<Tag state="selected" label="Selected" />

// Disabled
<Tag state="disabled" label="Disabled" />

Sizes

// Default size
<Tag label="Default" />

// Small size
<Tag size="small" label="Small" />

Accessibility

  • Keyboard accessible: Enter/Space to toggle, Delete/Backspace to remove
  • aria-selected for selection state
  • Remove button has accessible label
  • Disabled state announced to screen readers
  • Focus ring visible on keyboard navigation

Tag Props

PropTypeDefaultDescription
size'default' | 'small''default'Tag size.
state'default' | 'hovered' | 'selected' | 'selected-hovered' | 'disabled''default'Interactive state.
leadingItem'none' | 'icon' | 'brand' | 'avatar' | 'image' | 'country' | 'color''none'Type of leading visual element.
removablebooleantrueShow remove button.
labelstring'Tag'Tag label text.
iconComponentReact.ReactNodeCustom icon when leadingItem is "icon".
brandPlatformBrandPlatform'figma'Brand icon platform when leadingItem is "brand".
avatarPersonAvatarPerson'adam-smith'Avatar person when leadingItem is "avatar".
avatarType'image' | 'initials''image'Avatar display type.
avatarInitialsstring'PA'Avatar initials when avatarType is "initials".
imageSrcstringImage URL when leadingItem is "image".
countryCodeCountryCode'us'Country flag code when leadingItem is "country".
colorValuestring'var(--color-brand-primary-strong)'Color swatch value when leadingItem is "color".
onClick() => voidClick handler.
onRemove() => voidRemove button handler.

On this page