Jump To Page
- Stable
- WCAG 2.2 evidence
- RTL
A small "Go to page [48] of 120" control for long paged lists. Built on React Aria NumberField:
the visible label names the field, the total describes it, typed text is parsed in the user's locale (native digits
included) and the arrow keys step by 1 (WCAG 1.3.1, 2.1.1, 3.3.2, 4.1.2). Enter submits: a whole number from 1 to
pageCount calls onGoToPage; anything else shows an inline error with an icon (never colour alone) and announces it
assertively (3.3.1, 3.3.3, 4.1.3). It validates on submit, not on every key press, and nothing is clamped silently. Paste is
allowed. The enterkeyhint of the touch keyboard is "go". Consumer duties: translated label, total and error text; going to the page (and announcing it, see Pagination) in
onGoToPage. Use it only for lists with many pages.
import { JumpToPage } from "@nexera-ui/react";- 6
- examples
- 19
- props
- 3
- live controls
- 1
- platform
- 10
- WCAG criteria
- 0
- blocks use it
Try every prop. Copy the code.
Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.
import { JumpToPage } from "@nexera-ui/react";
<JumpToPage />Examples 5
The same examples as Storybook, rendered live. Open Code to copy one.
Empty
Empty field. Enter with an empty field, or a page outside 1 to 120, shows the error and announces it.
import { JumpToPage } from "@nexera-ui/react";
<JumpToPage pageCount={120} defaultValue={Number.NaN} />;
Goes to the page
Wired to a page state, like next to a Pagination: Enter with a valid page goes there.
import { useState } from "react";
import { JumpToPage } from "@nexera-ui/react";
export function GoesToThePage() {
function Demo() {
const [page, setPage] = useState(1);
return (
<div className="flex flex-col gap-3">
<JumpToPage pageCount={120} defaultValue={Number.NaN} onGoToPage={setPage} />
<p className="m-0 text-body-default text-primary">Showing page {page}</p>
</div>
);
}
return <Demo />;
}
Disabled
Disabled: not focusable, dimmed text.
import { JumpToPage } from "@nexera-ui/react";
<JumpToPage pageCount={120} defaultValue={48} isDisabled />;
Narrow width
A 320 px column: label, field and total wrap onto further lines instead of overflowing; the error wraps too.
import { JumpToPage } from "@nexera-ui/react";
export function NarrowWidth() {
return (
<div className="max-w-xs">
<JumpToPage
pageCount={120}
label="Gehe zu einer bestimmten Seite des Mitarbeiterverzeichnisses"
totalLabel="von insgesamt 120 Seiten"
errorMessage="Bitte eine ganze Zahl von 1 bis 120 eingeben, zum Beispiel 48."
defaultValue={500}
/>
</div>
);
}
Right to left
Right to left: the label starts at the right and the digits are the locale's own.
import { JumpToPage } from "@nexera-ui/react";
export function RightToLeft() {
return (
<JumpToPage
pageCount={120}
defaultValue={48}
label="انتقل إلى الصفحة"
totalLabel="من ١٢٠"
errorMessage="أدخل صفحة من ١ إلى ١٢٠"
/>
);
}
Props 19
Press "Try it" on a card to load that prop into the playground.
19 props shown
pageCount*NexeranumberNumber of pages (the largest page the user can go to). Figma Total shows it as "of 120"; it also bounds the
validation to the whole numbers 1 to pageCount.
labelNexerastringVisible label and accessible name of the field. Translate it.
totalLabelNexerastringText after the field. Read as the field's description. Translate it and format the number for your locale.
errorMessageNexerastring | ((pageCount: number) => string)Error text shown under the field, with an icon, when Enter is pressed with an empty field or a page outside 1 to
pageCount; it is also announced. A function receives pageCount. Say what to enter. Translate it.
valueNexeranumberThe typed page (controlled). NaN is an empty field. Use with onChange. React Aria commits the text on Enter and on
blur, so onChange is not called on every key press.
defaultValueNexeranumberThe page on first render (uncontrolled). NaN or omitted is an empty field.
onChangeNexera(value: number) => voidCalled with the committed number (NaN when the field is emptied).
onGoToPageNexera(page: number) => voidCalled with the page when Enter is pressed and the page is valid: a whole number from 1 to pageCount. Go to the
page here.
inputRefNexeraRef<HTMLInputElement>Ref to the native <input> (the root ref points to the field wrapper), for example to return focus after navigating.
classNameNexerastringExtra classes for the root, merged last so they win over the defaults.
styleNexeraCSSPropertiesInline style of the root.
commitBehaviorReact Aria"validate" | "snap"Controls the behavior of the number field when the user blurs the field after editing. 'snap' will clamp the value to the min/max values, and snap to the nearest step value. 'validate' will not clamp the value, and will validate that the value is within the min/max range and on a valid step.
isDisabledReact AriabooleanWhether the input is disabled.
isReadOnlyReact AriabooleanWhether the input can be selected but not changed by the user.
autoFocusReact AriabooleanWhether the element should receive focus on render.
idReact AriastringThe element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
aria-describedbyReact AriastringIdentifies the element (or elements) that describes the object.
nameReact AriastringThe name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).
formReact AriastringThe <form> element to associate the input with.
The value of this attribute must be the id of a <form> in the same document.
See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).
* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.
Accessible by default.
Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.
WCAG 2.2 evidence
7 direct · 3 supporting- 1.3.1Info and RelationshipsLevel A · tested directly
- 1.4.10ReflowLevel AA · supporting test
- 1.4.12Text SpacingLevel AA · supporting test
- 2.1.1KeyboardLevel A · tested directly
- 2.4.7Focus VisibleLevel AA · supporting test
- 3.3.1Error IdentificationLevel A · tested directly
- 3.3.2Labels or InstructionsLevel A · tested directly
- 3.3.3Error SuggestionLevel AA · tested directly
- 4.1.2Name, Role, ValueLevel A · tested directly
- 4.1.3Status MessagesLevel AA · tested directly
Fits any width.
Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.
Styling hooks
Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.
data-disabled
<JumpToPage className="data-disabled:opacity-90 shadow-sm" />Used in blocks
No block uses JumpToPage yet.
Related components
- BreadcrumbShows where the current page sits in the hierarchy and links back to each level.
- BreadcrumbItemOne level of a `Breadcrumb` trail; use it only inside `Breadcrumb`.
- CursorPagerA previous and next pair for data without stable page numbers, such as an activity log or a cursor API.
- FABThe main action of a mobile screen: a floating button with a `nav/active-bg` fill and a large shadow.
- FeedStatusThe status line at the bottom of an infinite feed or a lazy list: "Loading more", "You have reached the end" or "Could not load more" with a retry action.
- NavigationBarThe bottom bar of a mobile layout: a named `nav` landmark with a list of three to five `NavItem`s.
- NavItemOne destination or action of a `NavigationBar`.
- PageButtonOne page number of a `Pagination` or `TableFooter`.