Default
import { PixelChip } from '@pxlkit/ui-kit';
export function Default() {
return <PixelChip label="React" />;
}Compact label tag for representing tags, filters, or selections, optionally clickable or removable via an inline delete control.
onClick in React, @click in Vue, <button pxlChip> in Angular) for native keyboard + screen reader semanticsimport { PixelChip } from '@pxlkit/ui-kit';| Prop | Type | Default | Description |
|---|---|---|---|
label (required) | string | — | Chip label. |
value | string | — | Selection value consumed by a wrapping PixelChipGroup. Never rendered to the DOM. |
tone | 'green' | 'cyan' | 'gold' | 'red' | 'purple' | 'pink' | 'neutral' | 'cyan' | Tone tint. Defaults to 'cyan'. |
surface | 'pixel' | 'linear' | — | Visual surface override. |
variant | 'soft' | 'solid' | 'outline' | 'ghost' | 'soft' | Variant axis shared with PixelBadge. |
size | 'sm' | 'md' | 'lg' | 'md' | Size scale. Defaults to 'md'. |
iconLeft | React.ReactNode | — | Optional leading icon. |
onRemove | () => void | — | Legacy alias for onDelete. |
deletable | boolean | — | When true (or when onDelete is provided), renders an X button on the right. |
onDelete | () => void | — | Called when the X button is activated. |
onClick | React.MouseEventHandler<HTMLElement> | — | When provided the root renders as a <button>. With a delete handler too, a button cannot contain a button, so the label and the X become sibling buttons in a <span> frame that draws the chip; the label button takes the ref and the other props, the frame takes className. |
Also takes the native attributes and event handlers of its element (HTMLAttributes<HTMLElement>).
ref points to its element (HTMLElement).
WCAG target: 2.1 AA
buttonRenders as a <button> only when it handles clicks (onClick, @click in Vue, button[pxlChip] or clickable in Angular), so non-interactive chips stay static. The delete X is a <button> with aria-label "Remove <label>" that never fires the chip click; a button cannot contain a button, so on a clickable chip the label and the X are sibling buttons inside a <span> frame. On a clickable deletable chip the frame shows the label button's keyboard focus; the X shows its own.
| Key | Action | When |
|---|---|---|
| Enter | Activates the chip when onClick is provided | chip is focused |
| Space | Activates the chip when onClick is provided | chip is focused |
| Enter | Removes the chip via the X button | delete button is focused |
import { PixelChip } from '@pxlkit/ui-kit';
export function Default() {
return <PixelChip label="React" />;
}import { PixelChip } from '@pxlkit/ui-kit';
export function Default() {
return <PixelChip label="React" />;
}import { PixelChip } from '@pxlkit/ui-kit';
export function Tones() {
return (
<div className="flex flex-wrap gap-2">
<PixelChip label="Neutral" tone="neutral" />
<PixelChip label="Green" tone="green" />
<PixelChip label="Cyan" tone="cyan" />
<PixelChip label="Gold" tone="gold" />
<PixelChip label="Red" tone="red" />
<PixelChip label="Purple" tone="purple" />
<PixelChip label="Pink" tone="pink" />
</div>
);
}import { PixelChip } from '@pxlkit/ui-kit';
export function Sizes() {
return (
<div className="flex flex-wrap items-center gap-2">
<PixelChip label="Small" size="sm" />
<PixelChip label="Medium" size="md" />
<PixelChip label="Large" size="lg" />
</div>
);
}import { PixelChip } from '@pxlkit/ui-kit';
export function Variants() {
return (
<div className="flex flex-wrap gap-2">
<PixelChip label="Soft" variant="soft" tone="cyan" />
<PixelChip label="Solid" variant="solid" tone="cyan" />
<PixelChip label="Outline" variant="outline" tone="cyan" />
<PixelChip label="Ghost" variant="ghost" tone="cyan" />
</div>
);
}import { PixelChip } from '@pxlkit/ui-kit';
export function Surfaces() {
return (
<div className="flex flex-wrap gap-2">
<PixelChip label="Pixel" surface="pixel" tone="green" />
<PixelChip label="Linear" surface="linear" tone="green" />
</div>
);
}import { PixelChip } from '@pxlkit/ui-kit';
export function WithIcon() {
return (
<PixelChip
label="TypeScript"
tone="cyan"
iconLeft={<span aria-hidden>TS</span>}
/>
);
}import { PixelChip } from '@pxlkit/ui-kit';
export function Clickable() {
return (
<PixelChip
label="Click me"
tone="gold"
onClick={() => {
/* noop */
}}
/>
);
}import { useState } from 'react';
import { PixelChip } from '@pxlkit/ui-kit';
export function Deletable() {
const [visible, setVisible] = useState(true);
if (!visible) return null;
return (
<PixelChip
label="Remove me"
tone="red"
onDelete={() => setVisible(false)}
/>
);
}import { useState } from 'react';
import { PixelChip } from '@pxlkit/ui-kit';
export function ClickableAndDeletable() {
const [visible, setVisible] = useState(true);
if (!visible) return null;
return (
<PixelChip
label="Tag"
tone="purple"
onClick={() => {
/* select */
}}
onDelete={() => setVisible(false)}
/>
);
}