FormsFilterChips
Searchastronomic.dev# FilterChips
For the active filters under the bar, each a chip that removes it.
Static: no JavaScript.
## Usage
```astro
import FilterChips from "@astronomic-dev/ui/components/FilterChips.astro";
```
## Examples
### Active filters
Pick beds or a home type: each shows as a chip under the filters. Click a chip, or Tab to it and press Enter, to remove it.
```astro
---
import Filters from "@astronomic-dev/ui/components/Filters.astro";
import { fields, sorts } from "../_data/vega.ts";
const few = fields.filter((field) => field.key === "beds" || field.key === "type");
---
<Filters label="Filter homes" fields={few} sorts={sorts} defaults={{ sort: "newest" }} />
```
## Props
### FilterChips
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `class` | `string` | None | More classes for the <ul>, merged with cn(). |
Any other attribute goes on the <ul>. Filters renders it last; its script draws the chips from the template beside the list.
## Accessibility
| Key | Action |
| --- | --- |
| Enter or Space | Removes the chip's filter; focus moves to the next chip, else the first filter |
- A list of buttons, each named "Remove: 3+ beds": the visible text and an × icon hidden from screen readers.
- A choice with several values gives one chip per value; removing one unchecks only that option.
- The list is hidden while it is empty. Each chip is at least 44px on a touch screen.
FilterChips
FreeFor the active filters under the bar, each a chip that removes it.
- File
- FilterChips.astro
- Group
- Forms
- Kind
- Static: no JavaScript
- Examples
- 1
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Active filters
Pick beds or a home type: each shows as a chip under the filters. Click a chip, or Tab to it and press Enter, to remove it.
This preview did not load.
main.astro
examples/filterchips/main.astro
---
import Filters from "@astronomic-dev/ui/components/Filters.astro";
import { fields, sorts } from "../_data/vega.ts";
const few = fields.filter((field) => field.key === "beds" || field.key === "type");
---
<Filters label="Filter homes" fields={few} sorts={sorts} defaults={{ sort: "newest" }} />Minimal · Light