Skip to main content

Chip

A compact pill-shaped component used to represent selections, filters, or small entities. Supports selection state, removability, icons, sizes, and keyboard-accessible interaction.


Usage

Basic Chip

import { Chip } from '@nofinite/nui';

<Chip>React</Chip>

<Chip size="sm">Small chip</Chip>

Selectable Chip

<Chip selected onSelect={() => console.log('Selected')}>
Selected Chip
</Chip>

Removable Chip

<Chip removable onRemove={() => console.log('Removed')}>
Removable
</Chip>

Chip with Icons

<Chip iconLeft={<Icon />} iconRight={<Icon />}>
Messages
</Chip>

Interactive Chip

<Chip onSelect={() => console.log('Clicked')}>Clickable Chip</Chip>

Props

PropTypeDefaultDescription
childrenReact.ReactNodeContent displayed inside chip
removablebooleanfalseShows remove button
selectedbooleanfalseSelected visual state
iconLeftReact.ReactNodeIcon displayed before label
iconRightReact.ReactNodeIcon displayed after label
size'sm' | 'md''md'Chip size
onRemove() => voidCalled when remove button clicked
onSelect() => voidCalled when chip is selected
classNamestring""Additional CSS classes
...restReact.HTMLAttributes<HTMLDivElement>Native div props

Variants

Chip supports interaction-based variants.

<Chip />                       // Default chip
<Chip selected /> // Selected chip
<Chip onSelect={() => {}} /> // Interactive chip
<Chip removable /> // Removable chip

Available variants:

  • default – Static chip
  • selected – Active chip with highlighted background
  • interactive – Chip that responds to click and keyboard interaction
  • removable – Chip with remove action

Guidelines:

  • Use selected for filter or tag selection states.
  • Use interactive when chip triggers an action.
  • Use removable for dynamic lists like tags or recipients.

Sizes

SizeHeightFont SizeNotes
sm24px12pxCompact chips for dense UI
md32px14pxDefault size

States

StateDescription
defaultNeutral chip appearance
selectedHighlighted active state
interactiveHover + active feedback
removableDisplays remove control

Design Tokens / Theming

:root {
--nui-space-1: 4px;
--nui-space-2: 8px;
--nui-space-3: 12px;
--nui-radius-full: 9999px;
--nui-font-sans: 'Inter', sans-serif;
--nui-weight-medium: 500;
--nui-text-xs: 12px;
--nui-text-sm: 14px;

--nui-bg-surface: #ffffff;
--nui-bg-subtle: #f3f4f6;
--nui-border-default: #e5e7eb;
--nui-border-hover: #d1d5db;
--nui-brand-600: #2563eb;
--nui-brand-700: #1d4ed8;
--nui-fg-default: #111827;
}

Accessibility

  • Interactive chips receive role="button"
  • Keyboard interaction via Enter and Space
  • aria-pressed reflects selected state
  • Remove button is separately focusable and accessible
  • Focus-visible ring improves keyboard navigation

Best Practices

Do

  • Use chips for filters, tags, or selected items
  • Provide remove action for user-generated tags
  • Use selected state to show active filters
  • Keep chip text short

Don’t

  • Use chips for primary navigation
  • Overload chips with long content
  • Hide remove actions behind complex gestures