# Filterable Grid

> A directory grid for templates, integrations or work: filter pills with live counts, a search box that "/" jumps to, and a sort menu. Cards slide into place as the results change, and an empty state offers a way back. Generic over any item type with render and accessor props.

- Slug: `filterable-grid`
- Category: [Bento & Grids](https://www.assembli.design/category/bento-grids.md)
- Type: component
- Tags: filter, grid, directory, search, sort, gallery
- npm dependencies: @base-ui/react, lucide-react, motion
- shadcn/ui dependencies: none
- Live preview: https://www.assembli.design/preview/filterable-grid
- Page: https://www.assembli.design/components/filterable-grid

![Filterable Grid preview](https://www.assembli.design/thumbnails/filterable-grid-light.png)

## Props

Other props pass through to the root element.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` (required) | `T[]` |  |  |
| `getKey` (required) | `(item: T) => string` |  |  |
| `getCategory` (required) | `(item: T) => string \| string[]` |  | The filter value each item belongs to. Items can belong to several. |
| `getSearchText` | `(item: T) => string` |  | Text the search box matches against. Leave it out to hide the search box. |
| `renderItem` (required) | `(item: T) => React.ReactNode` |  |  |
| `filters` (required) | `GridFilter[]` |  | Filter tabs, in order. An "All" tab is added in front. Counts are worked out for you. |
| `allLabel` | `string` | `"All"` |  |
| `sorts` | `GridSort<T>[]` |  |  |
| `defaultFilter` | `string` | `ALL` |  |
| `onFilterChange` | `(value: string) => void` |  |  |
| `noun` | `{ one: string; other: string }` | `{ one: "result", other: "results" }` | The noun for the result count: `{ one: "template", other: "templates" }`. |
| `minItemWidth` | `string` | `"16rem"` | Cards never get narrower than this, as a CSS length. |
| `searchPlaceholder` | `string` | `"Search"` |  |

## Install

One-time setup (needs a subscription):

1. Add the registry to the project's `components.json`: `{"@assembli":{"url":"https://www.assembli.design/r/{name}.json","headers":{"Authorization":"Bearer ${ASSEMBLI_API_KEY}"}}}` (merge into `"registries"`).
2. Put an API key from https://www.assembli.design/account in `.env.local` as `ASSEMBLI_API_KEY=asm_…`.

Then install with the shadcn CLI (writes `components/filterable-grid/filterable-grid.tsx` and installs dependencies):

```bash
npx shadcn@latest add @assembli/filterable-grid
```

Registry item JSON: https://www.assembli.design/r/filterable-grid.json (send `Authorization: Bearer <api key>`)

## Code

> Component source needs an Assembli subscription ($12/month or $96/year) and an API key sent as `Authorization: Bearer <key>`. To get one without copying anything, POST https://www.assembli.design/api/agent/login (or call the MCP tool connect_account), show the user the link it returns, and poll https://www.assembli.design/api/agent/token for the key. Or subscribe at https://www.assembli.design/pricing and create a key at https://www.assembli.design/account.
