Todae

Todae

Chip

Text-only label. Optional remove is a named button. A +N count is a plain chip.

On this page
import { Chip, Stack, useStrings, VisuallyHidden } from '@tounsoo/todae';
import { X } from 'lucide-react';

export default function ChipExamples() {
  const { moreChips } = useStrings();
  return (
    <Stack.Root as="ul" direction="row" wrap align="center" aria-label="Chip examples">
      <li>
        <Chip.Root>Default</Chip.Root>
      </li>
      <li>
        <Chip.Root onRemove={() => undefined}>Removable</Chip.Root>
      </li>
      <li>
        <Chip.Root onRemove={() => undefined} removeIcon={<X strokeWidth={3} />}>
          Own icon
        </Chip.Root>
      </li>
      <li>
        <Chip.Root disabled onRemove={() => undefined}>
          Disabled
        </Chip.Root>
      </li>
      <li>
        <Chip.Root tone="success">Paid</Chip.Root>
      </li>
      <li>
        <Chip.Root tone="category-3" onRemove={() => undefined}>
          Design
        </Chip.Root>
      </li>
      <li>
        <Chip.Root aria-hidden>+4</Chip.Root>
        <VisuallyHidden.Root>{moreChips(4)}</VisuallyHidden.Root>
      </li>
    </Stack.Root>
  );
}
  • Default
  • Removable
  • Own icon
  • Disabled
  • Paid
  • Design
  • 4 more

The +N chip is hidden from assistive technology, and the visually hidden text beside it is read in its place. It is not a button and is not in the tab order.

tone takes the same tones as Badge: neutral, the default, the status tones info, success, warning and critical, and the category tones category-1 to category-8. neutral reads the chip.bg, chip.fg and chip.border state tokens; the other tones read the chip.<tone> contract tokens and keep their colors on hover. A disabled chip takes the disabled colors whatever its tone.

Without content, the remove button shows the close glyph: a cross, unless a GlyphsProvider sets one. Pass removeIcon to show a different icon for one chip; an svg or img takes the chip.icon.size token. The button's name still comes from removeLabel or its default. That default, Remove {label}, and moreChips, the {n} more to read for a +N chip, come from StringsProvider.

import { X } from 'lucide-react';

<Chip.Root onRemove={remove} removeIcon={<X />}>
  Design
</Chip.Root>

Accessible composition

Todae handles: Chip.Root renders its label as plain text in a <span> with no role. With onRemove, it adds a native <button type="button"> named by aria-label: removeLabel, or the removeChip string, Remove {label} in English. disabled disables that button and sets data-disabled on the chip.

You supply: List semantics when you show several chips: a <ul> with <li> items, or role="list" on the container and role="listitem" on each Chip.Root, which passes native props to its <span>. A name for that list. A removeLabel that says what is removed when the label alone is not enough, such as "Remove filter Design". Somewhere for focus to go after a removal: the remove button leaves the DOM with its chip, so move focus to a neighbouring chip or to the control that added it. ChipList does this for you.

Watch for: A chip inside a <button> or link: its remove button is then nested interactive content. A +N chip read as "plus 4": hide it with aria-hidden and put its name, moreChips(4) from useStrings, in a VisuallyHidden.Root beside it. A +N chip used as a control: it is a <span> that takes no focus. To make it open the rest, put it and its name inside a <button>, as ChipList does. Applied state shown only by chip color.

When to use

When: Text-only token for a value. Optional remove button via onRemove (named button). A display-only +N count.

When not: Typed tokens in an input → Field.ChipInput. Clickable or selectable chip → Button.Root / Checkbox (Chip has no select). Icons or rich content in the label (text only).

Props

Chip.Root props
NameTypeDescription
children Requiredstring

Chip label. Text only.

tone"neutral"| "info"| "success"| "warning"| "critical"| "category-1"| "category-2"| "category-3"| "category-4"| "category-5"| "category-6"| "category-7"| "category-8"

neutral reads the chip.bg, chip.fg and chip.border state tokens; other tones read the chip.<tone> contract tokens. A disabled chip takes the disabled colors instead.

Default: "neutral"

onRemove() => void

Renders a named remove button.

removeLabelstring

Remove button aria-label. Default is the removeChip string from StringsProvider, Remove {label} in English.

removeIconReact.ReactNode

Remove button content, such as an icon from your own set. Without it, the close glyph from GlyphsProvider, else Todae's cross.

disabledboolean

Disables the remove button.

Default: false