Chip
A compact token holding one short value: a tag, a filter, a status. It can also be made clickable or deletable.
tsx
import { Chip } from 'neba';
<Chip>design-system</Chip>
<Chip color="danger" count={12}>Errors</Chip>
<Chip onDelete={remove}>typescript</Chip>;Props
| Prop | Type | Default | Description |
|---|---|---|---|
| locale | string | — | BCP 47 tag naming the delete button in that language |
| variantshared | 'solid' | 'outline' | 'text' | 'outline' | Weight of the surface: filled, hairline, or none |
| sizeshared | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'md' | Height and type scale, one step below the control of the same size: a md chip is a sm control |
| colorshared | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'primary' | Semantic colour role. Arbitrary colour values are not accepted |
| densityshared | 'default' | 'compact' | 'default' | Padding only: never the height, never the type scale |
| elevationshared | 0 | 1 | 2 | 3 | 0 | Drop shadow depth. A chip sits on something else, so this is rarely raised |
| startIcon | ReactNode | — | Content before the label: an icon, a status dot, an avatar |
| endIcon | ReactNode | — | Content after the label, before any count |
| count | ReactNode | — | A number set into the end, on its own small plate |
| onClick | (event) => void | — | Passing it turns the label into a real button |
| onDelete | (event) => void | — | Passing it adds the delete button: its own button, separate from onClick |
| deleteLabel | string | — | Accessible name of the delete button |
| selected | boolean | false | Chosen. Deepens the surface a step rather than changing the colour family |
| disabled | boolean | false | Unavailable |
| children | ReactNode | — | The chip's label |
| transitionshared | NebaTransition | — | An entrance animation, run once on mount (transition="zoom"). Wrap it in an Animate* component for a trigger or a replay |
Chip's size sits one step below the control heights: an md Chip is 26px, the same height as a sm Button. That separates a token placed inside content from a control the row lines up against.
Examples
variant and color
startIcon · endIcon · count
startIcon and endIcon are nodes placed before and after the label. count gets its own plate, so "Errors 12" reads as one token with a number on it rather than as two words.
onClick · onDelete · selected
onClick makes the whole chip a pressable control. onDelete adds a delete button after the label. selected marks the chip as on by deepening the surface one step rather than changing the colour family.
size
Accessibility
- The shell is always a
<span>.onClickadds a<button>around the content;onDeleteadds a second<button>beside it. Neither is nested inside the other, so both are reachable by keyboard. - With more than one chip on screen, give the delete button a
deleteLabelnaming what is being removed: the default label leaves them indistinguishable. localedecides the delete button's accessible name;deleteLabelwrites it out instead.