# Filter chips

Active filters as removable chips, with Clear all. Renders nothing when there are none.

- Registry name: `filter-chips` (`@candor/filter-chips`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/filter-chips

## Install

```bash
npx candor-ui add filter-chips
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/filter-chips`.
It brings in: data, locale, utils.
npm packages: lucide-react@^1.67.0.

## Example

```tsx
"use client"

import * as React from "react"
import { FilterChips } from "@/components/filter-chips"
import type { FilterChip } from "@/lib/data"

const initial: FilterChip[] = [
  { id: "env", label: "Environment", value: "Production" },
  { id: "status", label: "Status", value: "Failed" },
  { id: "when", label: "Started", value: "Last 7 days" },
]

export default function Example() {
  const [filters, setFilters] = React.useState(initial)
  return <FilterChips filters={filters} onRemove={(id) => setFilters((all) => all.filter((f) => f.id !== id))} onClear={() => setFilters([])} />
}
```

## <FilterChips>

Props:

- `filters: FilterChip[]`: The active filters, each shown as label: value.
- `onRemove: (id: string) => void`: Called with a filter's id when its chip is removed.
- `onClear?: (() => void) | undefined`: Shows Clear all; called when it's clicked.
- `className?: string | undefined`

## Strings (`filterChips`)

The fixed words, English by default. Override any of them under `filterChips` in `<LocaleProvider strings={{ filterChips: { … } }}>`; the table is exported as `filterChipsStrings`.

- `remove`: Remove filter {label}: {value}
- `clearAll`: Clear all

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
