SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

Pager

A two-link pager for a feed paged in time or a sequence read in order, built from parts.

View code
tsx
<Pager aria-label="Older and newer posts">
	<Pager.Previous href="?page=1">Newer</Pager.Previous>
	<Pager.Status>Page 2 of 5</Pager.Status>
	<Pager.Next href="?page=3">Older</Pager.Next>
</Pager>

<Pager
	aria-label="More posts"
	mix={[raw({ "--ui-pager-link-inline-size": "100%", "--ui-pager-link-padding": "0.875rem 1rem" })]}
>
	<Pager.Previous href="?post=tuning-a-cache">
		<Pager.Caption>Previous</Pager.Caption>
		<Pager.Label>Tuning a cache by hand</Pager.Label>
	</Pager.Previous>
	<Pager.Next href="?post=quiet-deploys">
		<Pager.Caption>Next</Pager.Caption>
		<Pager.Label>Quiet deploys on a Friday</Pager.Label>
	</Pager.Next>
</Pager>

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Or copy it into your project to edit it:

Terminal
sdxc ui add pager

Usage

typescript
import { Pager } from "@sdxc/ui";

Renders a <nav> laid out as three columns, so Pager.Previous and Pager.Next each stay at their own end whether or not the other exists, with a Pager.Status centred between them; under 30rem wide the links stack. Restyle through Pager.CustomProperties.

Composition

The parts the component publishes, each a static property of the host.

  • Pager
  • Pager.PreviousThe link at the row's start, with an arrow pointing back; its words stack at its start.
  • Pager.NextThe link at the row's end, with an arrow pointing forward; its words stack at its end.
  • Pager.CaptionA small line over a link's label naming the direction, such as "Previous" over a post title.
  • Pager.LabelWhat a link says under its caption, such as "Older" or the title of the post it leads to.
  • Pager.StatusWhere the reader is, centred between the links, such as "Page 2 of 5".

Examples

tsx
<Pager layout="stack">
	<Pager.Previous href="/posts/one"><Pager.Caption>Previous</Pager.Caption><Pager.Label>The first post</Pager.Label></Pager.Previous>
</Pager>

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeDefaultRequiredDescription
layout"row" | "stack" | "auto"—NoHow the links sit. "auto" makes the root a size container, so give it a width of its own inside a shrink-to-fit parent.

Also accepts everything in TagProps<"nav">.

Pager.Previous

Pager.Next

Pager.Caption

Pager.Label

Pager.Status

Types

NameValuesWhat it decides
Layout"row" | "stack" | "auto"How the links sit: "row" at the two ends of one line, "stack" previous above next, each full width, and "auto" a row that stacks when the pager itself is under 30rem.
@sdxc/ui

Can’t find it? Contact us