Chip

Free

The small labelled pill of an AI product: context in a composer, a filter, a fact behind a decision and the citation after a claim, in one shape and one light grey.

npx shadcn@latest add https://pixilui.com/r/chip.json

Preview

A removed chip folds away while the row closes the gap.
Size

When to use

Use it when

  • Context attached to a prompt: files, repos, agents and people, each removable.
  • The evidence behind an agent's decision, as a fact chip with the figure set apart.
  • The source right after a claim, as a citation chip that opens its source card on hover or focus.

Use something else when

  • A row of filters that add up a total: use Chip group, which wires the pressed state and the rolling total.
  • A fixed fact about a run, such as Pass or Needs review: use a tag or badge (Badge).
  • Opening a menu: a menu opens from a button, never from a chip.

Installation

Terminal
npx shadcn@latest add https://pixilui.com/r/chip.json

Adds chip.tsx, and installs clsx and tailwind-merge. The URL works in any app with a components.json, with no registry to add first.

Usage

example.tsx
import { Chip } from "@/components/pixilui/chip";

<Chip onClick={onClick} onRemove={onRemove}>Save changes</Chip>

Chips wrap inside a ChipRow; a citation sits on the sentence's own line and wraps with it.

API reference

PropTypeDefault
size"md" | "sm""md"md 30 (the default), sm 26.
iconReactNode–A leading icon (an animated icon from packages/registry/icons).
dotstring–A leading status dot in this color (any CSS color or token, such as var(--pixilui-st-done-h)).
avatarstring–A leading avatar circle in this color, for a person.
favicon{ icon: ReactNode; color: string }–A leading favicon tile: the product's mark on its own color.
noteReactNode–The grey rest of a two-tone label: "Opus 5.5" with note "fast".
countnumber | string–A count after the label, grey (deep accent when pressed).

Also takes every native <span> attribute except onClick, and a ref.

Keyboard

TabMoves to each remove button, pressable chip and citation in turn.
Enter Backspace DeleteOn a remove button, removes the chip and moves focus to the next chip's remove, else the previous one, else the add chip.
EscCloses an open source card and keeps focus on its citation.

Accessibility

  • A chip at rest is a span; with pressed or onClick it is a button, and pressed writes aria-pressed.
  • The remove is a focusable role="button" named by removeLabel, such as "Remove refund-policy.md".
  • A citation is a button named "Source: name and name" with aria-expanded; its card is role="tooltip", tied with aria-describedby while open.
  • Every word passes 4.5:1 in both themes; disabled chips are muted to 55%.

Motion

  • A removed chip shrinks to nothing and fades in 180ms while the row closes the gap.
  • A chip added to a ChipRow after its first render grows from nothing, rising 2px, in 200ms.
  • A citation's card opens 120ms after hover or focus and grows from the chip's corner; it closes 140ms after the pointer leaves.
  • Hover tints and press scales in 150ms. Reduced motion: removed and added at once, the card without animation.

PixilUI Pro opens soon. The first 20 licenses are $99.