Pager
One page of a set at a time, such as onboarding cards, with previous, next, a dot per page, and a swipe left or right to move on or back.
Stability: experimental
Props
| Prop | Type | Default | Means |
|---|---|---|---|
label | string | What the pages are; the group's accessible name. | |
pages | { title: string; body?: string; image?: string }[] | The pages, each with a title, and text and a picture if it has them. | |
page | number | bindable(0) | The page shown, counted from 0. Bind it with bind:page={name}. |
States
| State | Looks like |
|---|---|
default | The current page in a card, then previous, the dots and next. |
at an end | Previous on the first page and next on the last are dimmed and cannot be pressed. |
Accessibility
| role | group |
| name | The label prop; each page is a group named n of count. |
| focus | Tab reaches previous, each dot, then next. |
| keyboard | Enter and Space press them. |
| notes | The current page's dot is marked aria-current. A swipe left on the page moves on and a swipe right back (on:swipe, decision 0121); the buttons do the same, so the swipe is never the only way. |
Theme tokens
color.surface color.border color.primary color.ink color.muted radius.md radius.full space.2 space.3 space.4 text.heading text.body
Example
<Pager label="Welcome" pages={welcome} bind:page={page} />