NUIv3.0.7

Chip

A composable, accessible Chip component for modern React applications.

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

Interactive Preview

Loading preview...

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

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

<Chip>React</Chip>

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

Selectable Chip

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

Removable Chip

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

Chip with Icons

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

Interactive Chip

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


Variants

Chip supports interaction-based variants.

tsx
<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


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

API Reference

PropTypeDefaultDescription
removablebooleanfalseIf true, renders a trailing 'X' button that triggers onRemove
selectedbooleanfalseControls the visual and ARIA active state of the chip
iconLeftReactNode
iconRightReactNode
sizeenummd
onRemove(() => void)Callback fired when the 'X' button is clicked
onSelect(() => void)Callback fired when the main body of the chip is clicked or activated via keyboard