Pills
The site's filters: small pills, orange-ink when picked, Steel Grey for All. Toggle buttons (aria-pressed) in a named group. On a touch screen each small pill gets a 44 px target without looking bigger; with scroll, on a phone, they are 44 px tall.
Preview
Filter, with counts and an "All" tab
84 places: Agra, Alleppey, Bangalore, Banikhet…
One row on a phone (scroll)
A single pill: pillVariants
Usage
import { Pills, pillVariants } from "zostel-ui";
<Pills
label="Landscape"
options={[{ value: "all", label: "All", count: 84 }, { value: "waters", label: "Waters", count: 16 }]}
value={family}
onChange={setFamily}
allValue="all"
scroll
/>
// one pill on its own (a toggle, a sort, a link)
<button className={pillVariants({ state: on ? "on" : "off" })}>Name</button>Pills
| Prop | Type | Default | Description |
|---|---|---|---|
options | { value: string; label: ReactNode; count?: number }[] | — | The tabs. A count shows after the label, in a lighter weight. |
value | string | — | The picked tab. |
onChange | (value: string) => void | — | Called with the tab's value. |
allValue | string | — | The value of the "All" tab: Steel Grey when picked, not orange-ink. |
label | string | — | The group's accessible name (its aria-label). |
scroll | boolean | false | On a phone: one row that scrolls sideways, edge to edge, each pill 44 px tall. |
className | string | — | More classes for the row, added beside its own. |
options{ value: string; label: ReactNode; count?: number }[]The tabs. A count shows after the label, in a lighter weight.
valuestringThe picked tab.
onChange(value: string) => voidCalled with the tab's value.
allValuestringThe value of the "All" tab: Steel Grey when picked, not orange-ink.
labelstringThe group's accessible name (its aria-label).
scrollbooleanfalseOn a phone: one row that scrolls sideways, edge to edge, each pill 44 px tall.
classNamestringMore classes for the row, added beside its own.
pillVariants
| Prop | Type | Default | Description |
|---|---|---|---|
state | "on" | "all" | "off" | "off" | on = orange-ink under white text; all = Steel Grey (the "All" tab only); off = white, a Beige line, muted text, the orange line on hover. |
state"on" | "all" | "off""off"on = orange-ink under white text; all = Steel Grey (the "All" tab only); off = white, a Beige line, muted text, the orange line on hover.