@dax-ui/chip
v0.8.0
Published
dax-ui Chip: status pills, tags and removable chips in outlined, soft, solid and glass styles
Maintainers
Readme
@dax-ui/chip
Compact labels for statuses, categories, tags and people. Four looks (outlined, soft,
solid, and glass for dark or gradient backgrounds), seven preset colors or any CSS
color, an optional icon or status dot, an accessible remove button, and click, toggle or
link behavior.
Installation
pnpm add @dax-ui/chipMUI and Emotion are included; the app only needs React 18 or 19.
One-time setup per app (skip if the app already uses dax-ui): install
@dax-ui/theme and wrap the app in its UIProvider.
pnpm add @dax-ui/themeUsage
import { Chip } from '@dax-ui/chip';
import { CalendarDays } from 'lucide-react';
// Status chips
<Chip label="Medium" color="success" dot />
<Chip label="Overdue" color="danger" />
<Chip label="Created by you" color="teal" />
// On a dark header
<Chip label="Event" variant="glass" />
// Removable (the button is named "Remove daniel Okafor")
<Chip label="daniel Okafor" color="teal" variant="solid" onDelete={() => remove(id)} />
// Filter toggle (aria-pressed)
<Chip label="Events" icon={<CalendarDays />} selected={on} onClick={() => setOn(!on)} />
// Link
<Chip label="Docs" href="/docs" variant="soft" color="info" />
// Any color, or single parts
<Chip label="Beta" color="#6d28d9" variant="solid" />
<Chip label="Custom" colors={{ background: '#fde68a', border: '#f59e0b', text: '#1e293b' }} />Colors
| color | Use |
| --- | --- |
| neutral (default) | Plain tags |
| brand | Dark teal, the modal headings and primary buttons |
| teal | Accent teal, e.g. "Created by you", participants |
| success, warning, danger, info | Statuses |
Presets have light- and dark-mode shades whose text passes 4.5:1 contrast. Any other
CSS color derives the border and fills with color-mix(); check its contrast yourself.
colors overrides single parts: text, background, border, icon, dot,
hoverBackground, focusRing. They're CSS variables (--dax-chip-<key>), so you can
also set them on an ancestor to recolor every chip inside it. CHIP_PALETTES and
CHIP_DARK_PALETTES hold the preset shades.
Props
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| label (required) | ReactNode | | Text of the chip. Also its accessible name. |
| aria-label | string | | Accessible name of a clickable chip or link, when the label alone isn't enough. |
| className | string | | Class name on the root element. |
| color | ChipPresetColor \| (string & {}) | neutral | A preset (neutral, brand, teal, success, warning, danger, info) or any CSS color, e.g. '#7c3aed', from which the text, border and fills are derived. Presets use the theme colors (teal is secondary); for a custom color, check contrast yourself. |
| colors | Partial<ChipColors> | | Overrides any of the chip's colors, e.g. { border: '#14b8a6' }. Unset keys come from color and variant. |
| deleteIcon | ReactNode | | Replaces the remove button's icon (a circled ×). |
| deleteLabel | string | 'Remove <label>' (or 'Remove' when the label isn't text) | Accessible name of the remove button. |
| disabled | boolean | false | Dims the chip and disables its buttons. |
| dot | string \| boolean | false | A small dot before the label, e.g. for a status or priority. true uses the chip's color; a string is a CSS color for the dot. |
| href | string | | Makes the chip a link to this URL. |
| icon | ReactNode | | Icon before the label, e.g. <FlagIcon />. Decorative: hidden from screen readers. |
| maxWidth | string \| number | | Longest the chip may grow, in px or any CSS length; longer labels end in "…". |
| onClick | ((event: MouseEvent<HTMLElement, MouseEvent>) => void) | | Makes the chip a button, e.g. for filters. |
| onDelete | ((event: MouseEvent<HTMLButtonElement, MouseEvent>) => void) | | Shows a remove button after the label, which calls this. |
| selected | boolean | false | Marks a clickable chip as selected (a toggle, aria-pressed): it switches to the solid look. |
| shape | "pill" \| "rounded" | pill | Corner style: a fully rounded pill or a rounded rectangle. |
| size | "sm" \| "md" \| "lg" | md | Height: sm 22px, md 28px, lg 34px. |
| style | CSSProperties | | Inline styles on the root element. |
| sx | SxProps<Theme> | | Style overrides on the root element. |
| target | string | | With href: where to open the link, e.g. '_blank'. |
| variant | "outlined" \| "soft" \| "solid" \| "glass" | outlined | Visual style. glass ignores color except for the dot. |
Other HTML attributes (id, title, data-*, …) go to the root <span>, which also
receives ref.
