Skip to content

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

PropTypeDefaultDescription
localestringBCP 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
elevationshared0 | 1 | 2 | 30Drop shadow depth. A chip sits on something else, so this is rarely raised
startIconReactNodeContent before the label: an icon, a status dot, an avatar
endIconReactNodeContent after the label, before any count
countReactNodeA number set into the end, on its own small plate
onClick(event) => voidPassing it turns the label into a real button
onDelete(event) => voidPassing it adds the delete button: its own button, separate from onClick
deleteLabelstringAccessible name of the delete button
selectedbooleanfalseChosen. Deepens the surface a step rather than changing the colour family
disabledbooleanfalseUnavailable
childrenReactNodeThe chip's label
transitionsharedNebaTransitionAn 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>. onClick adds a <button> around the content; onDelete adds 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 deleteLabel naming what is being removed: the default label leaves them indistinguishable.
  • locale decides the delete button's accessible name; deleteLabel writes it out instead.

Released under the MIT License