Chip

A compact token that can be selected or removed.

  • Composed
  • In the first release
import { Chip, chipPrimitive } from "nitro-ui-sdk/chip";
HeroUI Native
Chip
Expo UI
Chip
  • Chip example screen, light appearance
    Light
  • Chip example screen, dark appearance
    Dark
On this page

A compact capsule element for labels, filters, and removable tokens. Use Chip for individual status tags, standalone toggle filters, or dismissible tokens; use TagGroup to coordinate a wrapping set of selectable or removable tags.

Anatomy

<Chip.Root
  label="Design"
  icon="paintbrush"
  variant="soft"
  color="accent"
  selectable
  onRemove={() => {}}
  removeSlot={<Chip.Remove />}
>
  <Chip.Leading />
  <Chip.Label />
</Chip.Root>
Part Description
Chip.Root Capsule container managing visual variant, semantic intent, toggle/remove state, controller, and agent registration.
Chip.Leading Leading slot for an SF Symbol (icon prop) or custom leading node.
Chip.Label Text label styled to contrast with the active variant and intent.
Chip.Remove Dedicated 44 pt dismiss button with its own accessible name and optional confirmation.

Usage

import { Chip } from "nitro-ui-sdk/chip";

<Chip.Root label="Release" color="accent" />;

Variants and sizes

variant selects "primary" (default, solid fill), "secondary" (surface fill with border), "tertiary" (transparent with border), or "soft" (tinted soft surface). color accepts "default" (default neutral fill), "accent", "success", "warning", and "danger". size supports "sm", "md" (default), and "lg". Interactive chips always maintain at least a 44 pt touch target.

<Chip.Root label="Primary" variant="primary" color="accent" />
<Chip.Root label="Secondary" variant="secondary" color="success" />
<Chip.Root label="Tertiary" variant="tertiary" color="warning" />
<Chip.Root label="Soft" variant="soft" color="danger" />
<Chip.Root label="Featured" icon="star.fill" variant="soft" color="accent" size="sm" />

States

  • Selected: pass selected / defaultSelected or onToggle (or selectable) to make a chip toggleable. Selected chips elevate to their solid intent fill (or tokens.colors.accent when color="default").
  • Removable means the default anatomy includes Chip.Remove when you pass onRemove or removable. With custom children, pass removeSlot={<Chip.Remove />} to place the button beside the toggle. This slot also accepts a component that renders Chip.Remove.
  • Disabled: pass disabled to prevent toggling and removal and apply tokens.opacity.disabled.
<Chip.Root label="Unread" defaultSelected onToggle={() => {}} />
<Chip.Root label="Draft" onRemove={() => {}} removeLabel="Remove Draft" />
<Chip.Root label="Archived" disabled />

Controlled

Provide selected and onToggle to control filter selection. Calling details.preventDefault() declines the change.

import { useState } from "react";
import { Chip } from "nitro-ui-sdk/chip";

const [unread, setUnread] = useState(true);

<Chip.Root label="Unread" selected={unread} onToggle={setUnread} />;

Props

Chip.Root

Prop Type Default Description
label string — Required visible and accessible label.
icon string undefined Optional SF Symbol name rendered in Chip.Leading.
variant "primary" | "secondary" | "tertiary" | "soft" "primary" Surface treatment of the capsule.
color "default" | "accent" | "success" | "warning" | "danger" "default" Semantic intent palette.
size "sm" | "md" | "lg" "md" Visual height, padding, font, and icon scale.
selectable boolean true when selected, defaultSelected, or onToggle is set Enables toggle activation and selected state.
selected boolean undefined Controlled selected state.
defaultSelected boolean false Initial uncontrolled selected state.
onToggle (selected: boolean, details: ActionDetails) => void undefined Called before toggle state changes.
removable boolean true when onRemove, removeLabel, or a non-empty removeSlot is set Enables Chip.Remove and the remove action.
removeLabel string `Remove ${label}` Accessible name for Chip.Remove.
onRemove (details: ActionDetails) => void undefined Called when the chip is dismissed.
removeSlot ReactNode <Chip.Remove /> for removable chips with default anatomy Explicit remove content. Selectable chips render this slot beside the toggle.
removeConfirm Confirmation | (() => Confirmation) undefined Enables the destructive agent action with a localized { message, approveLabel, cancelLabel }.
confirm Confirmation undefined Alias for removeConfirm accepting a full Confirmation object.
disabled boolean false Disables toggle and remove interactions.
styles PartStyles<ChipPart, ChipVariant, ChipSize, ChipState> undefined Per-part style overrides.
api Controller<ChipActions> undefined Imperative controller created with chipPrimitive.createApi().
agentId string label Stable agent identity when rendered in lists.
layout SharedViewProps["layout"] undefined Additional layout props merged onto the root container.
children ReactNode Default anatomy Custom part composition, rendered as supplied.

Chip.Leading, Chip.Label, Chip.Remove

Prop Type Default Description
part ChipPart Matching part name Overrides the style slot resolved from styles.
children ReactNode / string Default icon/label/"×" Optional custom content or accessible remove label override.

Controller API

import { Chip, chipPrimitive } from "nitro-ui-sdk/chip";

const api = chipPrimitive.createApi();
<Chip.Root label="Unread" selectable api={api} />;
api.current?.toggle();
Action Signature Result
toggle (source?: ActionSource) => ChangeStatus Toggles a selectable chip ("unavailable" on non-selectable chips or handler-less controlled chips).
remove (source?: ActionSource) => ActionStatus Invokes onRemove on a removable chip ("unavailable" otherwise).

Styles

Style resolvers receive { tokens, variant, size, state } where state is { disabled: boolean; selected: boolean; color: ChipColor; selectable: boolean; removable: boolean; hasRemoveSlot?: boolean }. The root sets hasRemoveSlot when it renders a remove slot beside the main content.

<Chip.Root
  label="Custom"
  styles={{
    root: ({ tokens }) => ({ style: { cornerRadius: tokens.radius.sm } }),
  }}
/>

Accessibility

Static chips use role="text"; selectable chips use role="button" with selected; removable-only chips use role="group". When a selectable chip renders a remove slot, the outer pill uses a non-activating role="group" container and renders the toggle and the remove slot as siblings. Use removeSlot for custom anatomy so TalkBack and VoiceOver can reach both controls. Chip.Remove carries its own localized label (removeLabel or "Remove <label>") and a 44 pt touch target. Leading icons are decorative. Touch toggles fire selectionChanged() haptics and touch removals fire impact("light"). Assistive and keyboard activation report details.source === "user" without haptics.

Agent API

Action Arguments Notes
toggle none Registered when selectable is enabled; settles controlled updates against the committed selected value.
remove none Registered on the chip and Chip.Remove only when removable is enabled and removeConfirm (or confirm) is supplied. Touch removal works without removeConfirm.

Platform notes

iOS Android
Implementation Composed with Semantics, Icon (SF Symbols), and semantic tokens. Same composed layout with Semantics accessibility delegate; supply custom Chip.Leading fallback assets if Android icons are needed.
Verification Unit, type, iOS harness, and simulator screenshot verified. Shared TS/composed implementation; Android native build not run locally (no Android NDK on this machine).