NK

Search

Search pages, posts, and components

All components

Filter Chips

Inputs

A row of chips where clicking one makes it the active filter.

Installation

Add it with the shadcn CLI:

$pnpm dlx shadcn@latest add https://nawalkattel.com.np/r/filter-chips.json
Or install manually
  1. 1. Install dependencies

    pnpm add motion clsx tailwind-merge
  2. 2. Copy the component source into components/library/filter-chips.tsx

Props

PropTypeDefaultDescription
chipsstring[] - Chip labels, in order.
activenumber0Initially active index.
onChange(index: number) => void - Called with the new index on selection.

Accessibility

  • aria-pressed marks the active chip for assistive tech.
  • Selection changes background and border, not colour alone.
  • Wraps to multiple lines rather than scrolling out of reach.

Dependencies

motionclsxtailwind-merge