How to use
Chip is a compact pill for a tag, a status label, or one item in a set of selectable filters. It covers three related but distinct jobs: a plain static label, a closable tag with its own dismiss button, and a selectable/toggleable chip for filter-style UI — which one it is depends entirely on which props you pass.
import { Chip } from "oks-ui";With no onClose, Chip is a static, non-interactive label — for status tags ("Active", "Pending") that aren't meant to be dismissed. Pass onClose and Chip grows a close button automatically; onClose fires when it's pressed, and removing the chip from your own state list is on you.
<Chip color="success">Active</Chip>
<Chip onClose={() => removeTag(tag.id)} color="default">
{tag.label}
</Chip>Pass selected (controlled) or defaultSelected (uncontrolled) and Chip becomes a real toggleable control: role="button", aria-pressed reflecting the state, and both click and Enter/Space toggling it. Reach for this instead of onClose for a filter-style multi-select set of chips.
function TagFilter({ tags }: { tags: string[] }) {
const [active, setActive] = useState<Set<string>>(new Set());
return (
<div className="flex flex-wrap gap-2">
{tags.map((tag) => (
<Chip
key={tag}
selected={active.has(tag)}
onSelectedChange={(isSelected) => {
setActive((prev) => {
const next = new Set(prev);
isSelected ? next.add(tag) : next.delete(tag);
return next;
});
}}
variant="bordered"
>
{tag}
</Chip>
))}
</div>
);
}avatar renders at the very start of the chip (ahead of startContent), for a chip representing a person or entity with an image next to the label — a common pattern for a "tagged people" list. startContent/endContent sit around the label itself for anything else — an icon, a small count.
<Chip avatar={<Avatar size="xs" src={user.avatarUrl} />} onClose={() => untag(user.id)}>
{user.name}
</Chip>variant="dot" is a distinct fourth option alongside solid/soft/bordered — it renders a small colored dot ahead of the label instead of tinting the whole chip, a lighter-weight way to convey the same semantic color without as much visual weight.
<Chip variant="dot" color="success">Online</Chip>All available props for Chip. See the full component page for an interactive playground.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Chip label content. |
avatar | ReactNode | — | Avatar rendered at the start of the chip. |
startContent | ReactNode | — | Content rendered before the label. |
endContent | ReactNode | — | Content rendered after the label, before the close button. |
closeIcon | ReactNode | — | Overrides the default × close icon. |
children
ReactNode
Default: —
Chip label content.
avatar
ReactNode
Default: —
Avatar rendered at the start of the chip.
startContent
ReactNode
Default: —
Content rendered before the label.
endContent
ReactNode
Default: —
Content rendered after the label, before the close button.
closeIcon
ReactNode
Default: —
Overrides the default × close icon.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "solid" | "soft" | "bordered" | "dot" | solid | Visual style variant. |
shadow | "none" | "xs" | "xs-sm" | "sm" | "md" | "lg" | none | Box-shadow depth. |
size | "xs" | "xs-sm" | "sm" | "md" | "lg" | "xl" | md | Chip size. |
color | "default" | "primary" | "secondary" | "info" | "success" | "warning" | "danger" | default | Semantic color. |
radius | "none" | "xs" | "xs-sm" | "sm" | "md" | "lg" | "full" | full | Border radius. |
colorDepth | 50 | 100 | ... | 950 | 500 | Shade depth for the selected color. |
variant
"solid" | "soft" | "bordered" | "dot"
Default: solid
Visual style variant.
shadow
"none" | "xs" | "xs-sm" | "sm" | "md" | "lg"
Default: none
Box-shadow depth.
size
"xs" | "xs-sm" | "sm" | "md" | "lg" | "xl"
Default: md
Chip size.
color
"default" | "primary" | "secondary" | "info" | "success" | "warning" | "danger"
Default: default
Semantic color.
radius
"none" | "xs" | "xs-sm" | "sm" | "md" | "lg" | "full"
Default: full
Border radius.
colorDepth
50 | 100 | ... | 950
Default: 500
Shade depth for the selected color.
| Prop | Type | Default | Description |
|---|---|---|---|
isDisabled | boolean | false | Disables interaction. |
selected | boolean | — | Controlled selected state; renders as a toggleable role="button" chip. |
defaultSelected | boolean | — | Uncontrolled initial selected state. |
isDisabled
boolean
Default: false
Disables interaction.
selected
boolean
Default: —
Controlled selected state; renders as a toggleable role="button" chip.
defaultSelected
boolean
Default: —
Uncontrolled initial selected state.
| Prop | Type | Default | Description |
|---|---|---|---|
onClose | (e: PressEvent) => void | — | Shows a close button and is called when it's pressed. |
onSelectedChange | (selected: boolean) => void | — | Called when selected state changes. |
onClose
(e: PressEvent) => void
Default: —
Shows a close button and is called when it's pressed.
onSelectedChange
(selected: boolean) => void
Default: —
Called when selected state changes.
| Prop | Type | Default | Description |
|---|---|---|---|
classNames | Partial<Record<ChipSlot, string>> | — | Per-slot class overrides (base/content/dot/avatar/closeButton/endContent). |
className | string | — | Class applied to the root element. |
style | CSSProperties | — | Inline styles for the root element. |
classNames
Partial<Record<ChipSlot, string>>
Default: —
Per-slot class overrides (base/content/dot/avatar/closeButton/endContent).
className
string
Default: —
Class applied to the root element.
style
CSSProperties
Default: —
Inline styles for the root element.