NavigationFilterNav
Searchastronomic.dev# FilterNav
To switch between groups of a list, like work by service.
Static: no JavaScript.
## Usage
```astro
import FilterNav from "@astronomic-dev/ui/components/FilterNav.astro";
```
## Examples
### Filter by service
```astro
---
import FilterNav from "@astronomic-dev/ui/components/FilterNav.astro";
const filters = [
{ label: "All work", href: "#work", current: true },
{ label: "Brand identity", href: "#brand" },
{ label: "Websites", href: "#websites" },
{ label: "Product design", href: "#product" },
];
---
<FilterNav label="Filter by service" items={filters} />
```
### 44px on touch
touchTargets: on a touch screen each filter is a real box at least 44px each way, so no two hit areas overlap.
```astro
---
import FilterNav from "@astronomic-dev/ui/components/FilterNav.astro";
const filters = [
{ label: "All work", href: "#work", current: true },
{ label: "Brand identity", href: "#brand" },
{ label: "Websites", href: "#websites" },
{ label: "Product design", href: "#product" },
{ label: "Motion", href: "#motion" },
];
---
<FilterNav label="Filter by service" items={filters} touchTargets />
```
## Props
### FilterNav
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `{ label, href, current? }[]` | None | Required. The filters, as links. current marks the active one (aria-current="page"). |
| `label` | `string` | None | Required. Accessible name of the navigation, for example "Filter by service". |
| `touchTargets` | `boolean` | `false` | On a touch screen (a coarse pointer), each filter is a real box at least 44px each way (touchBox), so wrapped rows of pills never share a hit area. The pill grows to 44px tall on touch only. Opt-in only to keep other themes' HTML the same; the kit plans to make it the default at the next baseline. |
| `class` | `string` | None | More classes, merged with cn(), so yours win on conflicts. |
Any other attribute goes on the <nav>.
## Accessibility
- Renders a <nav> named by label, which is required, holding a list of links.
- The current filter gets aria-current="page" as well as its filled, bold look.
- Each filter is a plain link, so it works with no JavaScript.
- A pill is 32px tall by default; set touchTargets for a 44px box on touch (WCAG 2.5.5).
FilterNav
FreeTo switch between groups of a list, like work by service.
- File
- FilterNav.astro
- Group
- Navigation
- Kind
- Static: no JavaScript
- Examples
- 2
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Filter by service
44px on touch
touchTargets: on a touch screen each filter is a real box at least 44px each way, so no two hit areas overlap.
Minimal · Light