With Icon
A leading glyph or avatar.
import { Hash } from '@phosphor-icons/react';
<Chip icon={<Hash />}>release</Chip>A compact value: a tag, a filter or an applied selection, in one untoned look.
<Chip>Design</Chip>pnpm add @usefragments/uiImport styles once from @usefragments/ui/styles. See the installation guide for framework and theme setup.
Import Chip once, then compose its parts with dot notation.
Chip.GroupA leading glyph or avatar.
import { Hash } from '@phosphor-icons/react';
<Chip icon={<Hash />}>release</Chip>A toggle: the selection wash with the ring as its edge.
const [selected, setSelected] = React.useState(true);
<Chip selected={selected} onClick={() => setSelected((value) => !value)}>
Open
</Chip>The X control has its own label and a micro hit area.
<Chip onRemove={() => {}}>design</Chip>Shared selection, reported through onValueChange.
const [value, setValue] = React.useState(['open']);
<Chip.Group aria-label="Status filters" value={value} onValueChange={setValue}>
<Chip value="open">Open</Chip>
<Chip value="draft">Draft</Chip>
<Chip value="merged">Merged</Chip>Prop | Type | Default | Description |
|---|---|---|---|
childrenRequired | React.ReactNode | Not set | Chip label; truncates when the chip runs out of room |
Group.aria-label | string | undefined | Not set | — |
Group.aria-labelledby | string | undefined | Not set | — |
Group.childrenRequired | React.ReactNode | Not set | — |
Group.defaultValue | string[] | undefined | Not set | Default selected values (uncontrolled) |
Group.onValueChange | ((value: string[]) => void) | undefined | Not set | Called with the next selected values |
Group.value | string[] | undefined | Not set | Controlled selected values |
icon | React.ReactNode | Not set | Leading glyph or avatar |
onRemove | (() => void) | undefined | Not set | Makes the chip removable: an X control with its own label and a micro hit area |
removeLabel | string | undefined | "Remove <label>" for a text label, else "Remove" | Accessible name of the remove control; defaults to "Remove <label>" for a text label |
selected | boolean | undefined | Not set | Selected state. Setting it (or onClick, or Chip.Group) makes the chip a toggle button with aria-pressed; selected paints the selection wash and ring |
value | string | undefined | Not set | Value identifier used by Chip.Group for selection tracking |
disabled | boolean | undefined | false | Dims the chip once and disables its controls |
onClick | MouseEventHandler<HTMLButtonElement> | undefined | Not set | Click handler; makes the chip a button |
type | "button" | "submit" | "reset" | undefinedbuttonsubmitreset | button | — |