# FacetFilters

> The filters beside a product listing as one GET form: collapsible groups of checkboxes with counts, switches, a price range with buckets, and the applied filters as removable chips.

```ts
import { FacetFilters } from "@sdxc/ui/commerce";
```

Renders the form: the kept fields, the groups, then the Apply button, which hides once
AutoSubmit takes over submitting.

## Examples

```tsx
<FacetFilters action="/shop" keep={{ sort: "new" }} labels={{ apply: "Apply" }}><FacetFilters.Group title="Colour">…</FacetFilters.Group></FacetFilters>
```

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `action` | `string` | The listing page the filters submit to. |
| `keep?` | `Record<string, string>` | Query fields the form carries unchanged, such as the search and the sort. |
| `children` | `RemixNode` |  |
| `labels` | `Labels` |  |

Also accepts everything in `Omit<TagProps<"form">, "children" | "method" | "action">`.


### FacetFilters.Group

Renders a group as a `<details>` whose summary row carries the title and a chevron, open unless `open` is false.

| Prop | Type | Description |
| --- | --- | --- |
| `title` | `RemixNode` |  |
| `open?` | `boolean` |  |
| `children` | `RemixNode` |  |


### FacetFilters.Check

Renders a checkbox row.

| Prop | Type | Description |
| --- | --- | --- |
| `name` | `string` |  |
| `value` | `string` |  |
| `label` | `RemixNode` |  |
| `count` | `number` | How many results this value has with the other filters applied. |
| `checked?` | `boolean` |  |
| `swatch?` | `string` | A colour dot before the label, as any CSS colour or gradient. |


### FacetFilters.Toggle

Renders an on/off filter as a switch-styled checkbox that posts `1` while on.

| Prop | Type | Description |
| --- | --- | --- |
| `name` | `string` | The field that posts `1` while on. |
| `label` | `RemixNode` |  |
| `count` | `number` |  |
| `checked?` | `boolean` |  |


### FacetFilters.Range

Renders two number fields side by side, then the bucket links with their counts.

| Prop | Type | Description |
| --- | --- | --- |
| `minName` | `string` |  |
| `maxName` | `string` |  |
| `min?` | `number \| null` |  |
| `max?` | `number \| null` |  |
| `labels` | `{ min: string; max: string }` | The two fields' labels, such as "Min" and "Max". |
| `prefix?` | `string` | A symbol before each figure, such as "$". |
| `buckets?` | `Bucket[]` |  |


### FacetFilters.Applied

Renders the applied filters as a row of chips, each a link to the listing without that filter, then a "Clear all" link.

| Prop | Type | Description |
| --- | --- | --- |
| `chips` | `Chip[]` |  |
| `clear?` | `{ label: string; href: string }` | A link to the listing with every filter removed. |
| `label` | `string` | The row's accessible name, such as "Applied filters". |

