Tag
import { Tag } from "@cherry-design-system/react";
export function Topic() {
return <Tag>React</Tag>;
}A Tag shows a value, such as a selected filter or a topic, and can be removable. Removal shrinks and fades the chip out. For a read-only status label, use Badge.
Examples
Variants and sizes
import { Tag } from "@cherry-design-system/react";
export function Variants() {
return (
<>
<Tag variant="neutral">Neutral</Tag>
<Tag variant="accent">Accent</Tag>
<Tag variant="outline">Outline</Tag>
<Tag size="sm">Small</Tag>
</>
);
}Removable list
Passing onRemove shows the remove button. It is called once the exit animation has finished, so drop the tag from your state there.
"use client";
import { useState } from "react";
import { Tag } from "@cherry-design-system/react";
export function Filters() {
const [tags, setTags] = useState(["React", "TypeScript", "CSS"]);
return (
<div style={{ display: "flex", gap: 8, flexWrap: "wrap" }}>
{tags.map((tag) => (
<Tag
key={tag}
variant="outline"
onRemove={() => setTags((current) => current.filter((t) => t !== tag))}
>
{tag}
</Tag>
))}
</div>
);
}Disabled
disabled disables the remove button.
import { Tag } from "@cherry-design-system/react";
export function Locked() {
return (
<Tag disabled onRemove={() => {}}>
Required
</Tag>
);
}Properties
Visual style. Defaults to "neutral".
Chip size. Defaults to "md".
Shows the remove button. Called once the exit animation has finished: drop the tag from your list there.
Remove button name, followed by the tag text. Defaults to "Remove".
Disables the remove button.
Tag renders a <span>, forwards its ref to it and passes every other <span> attribute through. It is a client component.
Styling
| Hook | Values |
|---|---|
.cherry-tag | Root element |
data-variant | neutral, outline, accent |
data-size | sm, md |
data-exiting | Present during the remove animation |
| Parts | .cherry-tag__label, .cherry-tag__remove |
neutral reads --cherry-bg-muted, accent reads --cherry-accent-subtle and --cherry-accent-fg, and outline reads --cherry-border-default.
Accessibility
- The remove button is named by
removeLabelplus the tag text, for example "Remove React". Translate it withremoveLabel. - With the remove button focused, Backspace or Delete removes the tag.
- Don't rely on color alone to carry meaning.