Skip to content

Feedback

Tag

tsx
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

tsx
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.

tsx
"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.

tsx
import { Tag } from "@cherry-design-system/react";

export function Locked() {
  return (
    <Tag disabled onRemove={() => {}}>
      Required
    </Tag>
  );
}

Properties

variant"neutral" | "accent" | "outline"

Visual style. Defaults to "neutral".

size"sm" | "md"

Chip size. Defaults to "md".

onRemove() => void

Shows the remove button. Called once the exit animation has finished: drop the tag from your list there.

removeLabelstring

Remove button name, followed by the tag text. Defaults to "Remove".

disabledboolean

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

HookValues
.cherry-tagRoot element
data-variantneutral, outline, accent
data-sizesm, md
data-exitingPresent 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 removeLabel plus the tag text, for example "Remove React". Translate it with removeLabel.
  • With the remove button focused, Backspace or Delete removes the tag.
  • Don't rely on color alone to carry meaning.