Pagination
A page navigator that coordinates first, previous, next, last, and page input controls.
Usage
Use as a coordinator around ComboBox.
<Pagination comboBox={{ placeholder: "Page" }} />
<Pagination>
<ComboBox />
</Pagination>Anatomy
The class attribute values represent part names. Other attributes represent their corresponding props. An embedded ComboBox renders between the left and right buttons unless children is supplied.
<nav class="whole" aria-label>
<button class="top" type="button" aria-label aria-disabled>{top}</button>
<button class="left" type="button" aria-label aria-disabled>{left}</button>
{#if children}{children}{:else}<ComboBox />{/if}
<button class="right" type="button" aria-label aria-disabled>{right}</button>
<button class="bottom" type="button" aria-label aria-disabled>{bottom}</button>
</nav>- The page commits on ComboBox blur, Enter, and option select; invalid input reverts and out-of-range input clamps.
- Buttons use
aria-disabled, stay focusable at bounds, and suppress their action while at-bound. - Part names map by position: TOP=first, LEFT=prev, RIGHT=next, BOTTOM=last.
- Embedded
ComboBoxis wired through context;comboBoxis ignored whenchildrenis supplied. onchangefires a nativechangeEvent after user-initiated page changes (nav buttons or ComboBox commits); read the new page from boundvalue. Programmatic value changes and bound clamping do not fire it.- The default shortcut list is centered on the current page. A caller-provided
optionslist can follow the page withbind:value={page}andconst opts = $derived(...); no change event is needed.
Props
| Name | Type | Default | Description |
|---|---|---|---|
children | Snippet | - | Custom pagination content; receives value and variant |
value | number | 1 | Bindable current page |
min | number | 1 | First page |
max | number | - | Last page; defaults to max(min, value) |
options | number[] | - | Shortcut page numbers shown by the embedded ComboBox |
top | Snippet | - | FIRST button content; receives value and variant |
left | Snippet | - | PREV button content; receives value and variant |
right | Snippet | - | NEXT button content; receives value and variant |
bottom | Snippet | - | LAST button content; receives value and variant |
ariaLabel | string | "Pagination" | Accessible label for the nav landmark |
buttonLabels | PaginationLabel | - | Accessible labels for the buttons; defaults First/Previous/Next/Last page |
comboBox | ComboBoxProps | - | Config bag spread into the embedded ComboBox; uses the flat inner-prop shape and is ignored when children is supplied |
styling | SVSClass | - | Styling override |
variant | SVSVariant | NEUTRAL | Variant |
Other <nav> attributes are passed to <nav> via rest props; class is merged onto the root.
Styling
To learn more, see Styling.
Variant Management
The FIRST and PREV buttons render with VARIANT.INACTIVE while value is at min; NEXT and LAST render with VARIANT.INACTIVE while value is at max.
Default Class Name
svs-pagination
Behavior
- The page commits on ComboBox blur, Enter, and option select; invalid input reverts and out-of-range input clamps.
- Buttons use
aria-disabled, stay focusable at bounds, and suppress their action while at-bound. - Part names map by position: TOP=first, LEFT=prev, RIGHT=next, BOTTOM=last.
- Embedded
ComboBoxis wired through context;comboBoxis ignored whenchildrenis supplied. onchangefires a nativechangeEvent after user-initiated page changes (nav buttons or ComboBox commits); read the new page from boundvalue. Programmatic value changes and bound clamping do not fire it.- The default shortcut list is centered on the current page. A caller-provided
optionslist can follow the page withbind:value={page}andconst opts = $derived(...); no change event is needed.
Accessibility
ARIA Roles and Attributes
The component applies these automatically:
- Navigation (
whole<nav>):aria-label, defaulting to"Pagination"and overridable withariaLabel. - Boundary buttons (
top,left,right,bottom<button>):aria-labelfrombuttonLabels.top,buttonLabels.left,buttonLabels.right, orbuttonLabels.bottom, andaria-disabledwhile the button is at its first-page or last-page boundary. - Button icons (
<svg>):aria-hidden="true"andfocusable="false".
The boundary buttons stay focusable at their bounds and suppress their action instead of leaving the tab order. When the jump control is rendered by the default ComboBox, see ComboBox for its ARIA attributes and keyboard behavior.
Standards Basis
Pagination's boundary controls are native <button> elements, so keyboard and assistive-technology support follows the browser standard for button controls. See the Concepts standards-first guidance for the library's approach.
Exports
Types
type PaginationLabel = { top?: string; left?: string; right?: string; bottom?: string };
interface PaginationProps extends Omit<HTMLAttributes<HTMLElement>, "children" | "aria-label"> {
children?: Snippet<[number, string]>; // Snippet<[value,variant]>
value?: number; // bindable; current page (default 1)
min?: number; // first page (default 1)
max?: number; // last page (default = max(min, value))
options?: number[]; // shortcut list shown in the ComboBox
top?: Snippet<[number, string]>; // Snippet<[value,variant]>; FIRST button content
left?: Snippet<[number, string]>; // Snippet<[value,variant]>; PREV button content
right?: Snippet<[number, string]>; // Snippet<[value,variant]>; NEXT button content
bottom?: Snippet<[number, string]>; // Snippet<[value,variant]>; LAST button content
ariaLabel?: string; // ("Pagination")
buttonLabels?: PaginationLabel; // ({top:"First page",left:"Previous page",right:"Next page",bottom:"Last page"})
comboBox?: Omit<ComboBoxProps, ComboBoxReqdProps | ComboBoxBindProps | "options" | "variant" | "styling">;
styling?: SVSClass;
variant?: SVSVariant; // (VARIANT.NEUTRAL)
// other nav attributes are passed to <nav> via ...rest; `class` is merged onto root
}
type PaginationReqdProps = never;
type PaginationBindProps = "value";Others
No additional exports are available.
Examples
The example code uses Tailwind CSS along with SVSClass.