Data display
Chip
Free12.8 KB gzippedA compact pill for tags, filters, and selections. Unlike Badge, a chip can be removable (onRemove), clickable (onClick or href), or selectable (selected / onSelectedChange, or value in a ChipGroup).
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Enter, Space, Backspace and 1 more · Full report
Import
import { Chip, ChipGroup } from "@vjdesigns/vjdesigns-ui";
Importing only Chip adds about 12.8 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Variants
import { Avatar, Chip, Flex, Stack } from "@vjdesigns/vjdesigns-ui";
export function Variants() {
return (
<Stack gap={3} align="center">
<Flex gap={2} wrap="wrap" justify="center">
<Chip variant="soft">Soft</Chip>
<Chip variant="solid" tone="primary">
Solid
</Chip>
<Chip variant="outline">Outline</Chip>
</Flex>
<Flex gap={2} wrap="wrap" justify="center">
<Chip avatar={<Avatar name="Jordan Lee" colorFromName />}>Jordan Lee</Chip>
<Chip tone="success">Shipped</Chip>
<Chip tone="warning">In review</Chip>
</Flex>
</Stack>
);
}
Removable
With onRemove, a chip gets a remove button. Backspace or Delete removes a focused chip.
import { useState } from "react";
import { Chip, ChipGroup } from "@vjdesigns/vjdesigns-ui";
export function Removable() {
const [filters, setFilters] = useState(["Open", "Assigned to me", "High priority"]);
return (
<ChipGroup aria-label="Active filters">
{filters.map((filter) => (
<Chip key={filter} onRemove={() => setFilters((current) => current.filter((f) => f !== filter))}>
{filter}
</Chip>
))}
</ChipGroup>
);
}
Filter chips
With selectionMode, a ChipGroup works like a set of toggle buttons for filtering.
Showing: react
import { useState } from "react";
import { Chip, ChipGroup, Stack, Text } from "@vjdesigns/vjdesigns-ui";
export function FilterChips() {
const [selected, setSelected] = useState(["react"]);
return (
<Stack gap={3} align="center">
<ChipGroup selectionMode="multiple" value={selected} onValueChange={setSelected} aria-label="Frameworks" variant="outline">
<Chip value="react">React</Chip>
<Chip value="angular">Angular</Chip>
<Chip value="vue">Vue</Chip>
<Chip value="svelte">Svelte</Chip>
</ChipGroup>
<Text size="sm" tone="muted">
Showing: {selected.join(", ") || "everything"}
</Text>
</Stack>
);
}
Accessibility
Filter chips are toggle buttons: they expose aria-pressed and show a check icon, so the selected state isn't color alone. Every remove button has its own name, here "Remove filter: Size M".
import { useState } from "react";
import { Chip, ChipGroup, Flex, Stack } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
const [filters, setFilters] = useState(["Size: M", "Color: Blue"]);
return (
<Stack gap={4}>
<ChipGroup aria-label="Filter by status" selectionMode="multiple" defaultValue={["open"]}>
<Chip value="open">Open</Chip>
<Chip value="closed">Closed</Chip>
<Chip value="draft">Draft</Chip>
</ChipGroup>
<Flex gap={2} wrap="wrap">
{filters.map((filter) => (
<Chip
key={filter}
removeLabel={`Remove filter: ${filter.replace(": ", " ")}`}
onRemove={() => setFilters((all) => all.filter((f) => f !== filter))}
>
{filter}
</Chip>
))}
</Flex>
</Stack>
);
}
Translated
Without a removeLabel, each remove button is named from the locale and the chip's text (Spanish here).
import { useState } from "react";
import { Chip, Flex, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import es from "@vjdesigns/vjdesigns-ui/locales/es";
export function Translated() {
const [chips, setChips] = useState(["Talla: M", "Color: azul", "En oferta"]);
return (
<LocaleProvider locale="es" messages={es}>
<Flex gap={2} wrap="wrap">
{chips.map((chip) => (
<Chip key={chip} onRemove={() => setChips((all) => all.filter((c) => c !== chip))}>
{chip}
</Chip>
))}
</Flex>
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Variants
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// Variants is the "Variants" example above.
<LocaleProvider locale="ar" messages={ar}>
<Variants />
</LocaleProvider>
Usage notes
- Static: a
<span>. A remove button, if any, is its only tab stop. - Clickable: a
<button>or<a>. - Selectable: a
<button aria-pressed>with a check icon when selected. - Interactive and removable: the action and the remove button are sibling buttons inside one pill (never nested).
API reference
Chip
| Prop | Type | Default |
|---|---|---|
childrenThe chip label. Long labels truncate with an ellipsis; the full text stays in the accessible name and in a | ReactNode | — |
variantVisual style. Inside a | "solid""soft""outline" | "soft" |
toneSemantic color. Inside a | "neutral""primary""accent""success""warning""danger""info" | "neutral" |
sizeHeight, padding, and type size. Inside a | "sm""md""lg" | "md" |
radiusCorner rounding. | "none""xs""sm""md""lg""xl""2xl""pill" | "pill" |
startIconDecorative icon before the label. Hidden from assistive technology, so the label must carry the meaning. | ReactNode | — |
avatarA small avatar before the label, e.g. | ReactNode | — |
onRemoveMakes the chip removable: shows a remove button (a real | () => void | — |
removeLabelAccessible name of the remove button. | string | "Remove {label}" |
removeTabIndex
| number | — |
disabledDisables the chip and its remove button. Inside a | boolean | false |
selectedSelected state for a filter chip (controlled). Setting | boolean | — |
defaultSelectedInitial selected state when uncontrolled. | boolean | — |
onSelectedChangeCalled with the next selected state when the chip is toggled. | (selected: boolean) => void | — |
valueValue of this chip inside a | string | — |
hrefMakes the chip a link. Ignored when the chip is selectable. | string | — |
targetLink target (with | ComponentPropsWithoutRef<"a">["target"] | — |
relLink relationship (with | string | — |
downloadDownload hint (with | ComponentPropsWithoutRef<"a">["download"] | — |
onClickClick handler. Makes the chip a | MouseEventHandler<HTMLElement> | — |
onKeyDownKey handler on the chip's interactive element (or its root when static). Call | KeyboardEventHandler<HTMLElement> | — |
refRef to the chip's primary element: the | Ref<HTMLElement> | — |
Also accepts native <button> attributes, plus className, style and ref.
ChipGroup
Lays out chips with a gap and wraps them. As a tag list (role="list", the default), each chip becomes a listitem. With selectionMode, it is a role="group" that manages selected chips by their value.
After a chip is removed, focus moves to the next chip, else the previous one, else focusFallback, else the group itself.
| Prop | Type | Default |
|---|---|---|
role
| "list""group" | — |
sizeSize for every chip (a chip's own | "sm""md""lg" | "md" |
variantVariant for every chip (a chip's own | "solid""soft""outline" | — |
toneTone for every chip (a chip's own | "neutral""primary""accent""success""warning""danger""info" | — |
disabledDisables every chip in the group. | boolean | false |
focusFallbackWhere focus goes when the last remaining chip is removed. Without it, the group container itself receives focus. | ChipFocusFallback | — |
children
| ReactNode | — |
selectionModeLets the group manage selectable chips (each needs a | "single""multiple" | — |
valueControlled value: the selected chip's value, or | string | null | string[] | — |
defaultValueInitial value when uncontrolled. | string | null | string[] | null |
onValueChangeCalled with the next value ( | (value: string | null) => void | (value: string[]) => void | — |
aria-labelDefines a string value that labels the current element. | string | — |
aria-labelledbyIdentifies the element (or elements) that labels the current element. | string | — |
Also accepts standard HTML attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Chip targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| EnterSpace | Toggles a selectable chip, or activates a clickable one. |
| BackspaceDelete | Removes a removable chip when it has focus; focus moves to the next chip. |
Roles and states
| Element | Role | States and properties |
|---|---|---|
| Selectable chip | button | aria-pressed |
| Remove button | button | aria-label ("Remove …") |
ChipGroup | list or group | aria-label; chips are list items |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |