Skip to Content

Chip

A small label/tag component with optional remove functionality. Uses the ClearButton component internally for the dismiss action.

Import

import { Chip } from "chunks-ui";

Basic Usage

<Chip>Default</Chip>
Default

Colors

<Chip color="primary">Primary</Chip> <Chip color="destructive">Destructive</Chip> <Chip color="success">Success</Chip> <Chip color="warning">Warning</Chip> <Chip color="secondary">Secondary</Chip>
PrimaryDestructiveSuccessWarningSecondary

Each color applies a light tinted background with matching text and border (e.g. bg-primary/10 text-primary-text border-primary/30).

Variants

The variant prop controls the fill style:

<Chip variant="contained" color="primary">Contained</Chip> <Chip variant="outlined" color="primary">Outlined</Chip>
ContainedOutlined

The outlined variant removes the background fill, keeping only the border and text color.

Removable Chip

Pass an onRemove callback to show a close button:

function TagList() { const [tags, setTags] = useState(["React", "TypeScript", "Tailwind"]); return ( <div className="flex gap-2"> {tags.map((tag) => ( <Chip key={tag} onRemove={() => setTags((prev) => prev.filter((t) => t !== tag))} > {tag} </Chip> ))} </div> ); }
ReactTypeScriptTailwind

The remove button reads its label and then the chip’s text, for example “Remove React”. To put the chip’s text first, mark its place with {chip}: labels={{ remove: "{chip} を削除" }} reads “React を削除”. See Labels.

Props

NameTypeDefault
color"primary" | "destructive" | "success" | "warning" | "secondary"

Semantic color of the chip.

"secondary"
variant"contained" | "outlined"

Fill style of the chip.

"contained"
onRemove() => void

Callback fired when the remove button is clicked; shows a remove button when provided.

labelsPartial<ChipLabels>

Replaces the built-in English strings, e.g. to translate them. Keys you leave out keep the default from DEFAULT_CHIP_LABELS.

All other props are forwarded to the underlying <span> element.

Labels

labels replaces the built-in English text, for example to translate it. Keys you leave out keep their default from DEFAULT_CHIP_LABELS. See Labels.

NameTypeDefault
removestring

Name of the remove button, read with the chip’s text. {chip} marks where the text goes: "{chip} を削除" reads “Apple を削除”. Without {chip}, the text follows the label, so the default reads “Remove Apple”. Only the first {chip} counts.

"Remove"
Last updated on