@zendeskgarden/react-tags package provides the Tag component with subcomponents for avatars and close buttons. Tags are compact labels used to categorize content, show attributes, or let users remove applied filters.
Installation
Tag
Wrap your app inThemeProvider before using any Garden component.
Size
Thesize prop adjusts font size and padding. The default is medium.
Color (hue)
Use thehue prop to apply a color to the tag. You can pass a primary hue name, a theme color token, or any hex value.
- Named hues
- Theme tokens
- Hex value
Named hues (
blue, green, grey, kale, red, yellow) and theme tokens (primaryHue, successHue, etc.) automatically adapt to light and dark mode. Raw hex values do not adapt.Pill style
SetisPill to apply fully rounded corners. This is commonly used alongside Tag.Avatar.
Round style
SetisRound to render a symmetrical, circular tag. Best used for single characters or numbers.
Regular font weight
By default, tag text is bold. SetisRegular to use normal font weight.
Tag.Avatar
NestTag.Avatar as the first child of Tag to display a small image or icon inside the tag. Pair it with isPill for the best visual result.
Tag.Close
AddTag.Close as the last child of Tag to show a remove button. Provide an aria-label describing what will be removed. When the tag contains a close button, make the tag itself focusable by setting tabIndex={0}.
Full example
Props
Tag
Adjusts font size and padding.
Sets the tag color. Accepts primary hues (
blue, green, grey, kale, red, yellow), theme tokens (primaryHue, successHue, neutralHue, chromeHue, dangerHue, warningHue), or any hex value.Applies fully rounded (pill) styling.
Applies circular styling. Best for single characters or numbers.
Applies regular (non-bold) font weight.
Tag.Close
Accessible label for the close button. Should describe the item being removed.
Called when the close button is clicked.