Load More

A button that adds the next page to a list, in place, without the page jumping.

AP
Ada Park

rotated the API key prod-ingest

7m ago
SR
Sam Rivera

updated the billing email

14m ago
PS
Priya Shah

invited sam@example.com

21m ago
JK
Jonah Kim

turned on SSO

28m ago
LO
Lena Ortiz

changed the plan to Team, billed yearly

35m ago

Showing 5 of 18

Installation

  1. Add the registryOnce per project
  2. Add load-more

Usage

onLoadMore fetches the next page and adds it to your state. Return a promise, so the button knows when it's done. LoadMoreContent holds the rows in whatever markup suits them, such as an Item group, a list or a grid of cards, and its direct children are the rows. Give it render to make it a ul or a tbody. count is how many rows are shown, so the count is right before the page loads its scripts. Without it, the rows are counted in the browser.

When a page lands, its rows fade in, and focus moves to the first of them, so someone using a keyboard or screen reader carries on from what they asked for. A screen reader also hears how many arrived. The button and count opt out of scroll anchoring, so new rows push them down rather than moving what you're reading. The spinner shows only once a page has taken pendingDelay milliseconds, and stays at least minPending, so it never flickers. A second press while a page loads does nothing, and once hasMore is false, the button gives way to a marker at the end.

Composition

Examples

Errors

If onLoadMore rejects, the rows loaded so far stay, and the button offers to try again, with a message under it. Here the first try fails.

  • #4120main
  • #4119billing-flag
  • #4118sso-azure
  • #4117export-s3

Showing 4 of 12

Loading on scroll

auto loads the next page on its own as the button comes within 200 pixels of view, in the window or a scrolling container, so the list keeps going as you read. Focus stays where it is. After a failure, or a page that adds no rows, it waits for a press rather than asking again.

Props

The tables leave out className, style and render. Parts built on Base UI take them as its styling and composition guides describe.

LoadMore

LoadMoreButton

LoadMoreCount

LoadMoreButton takes the props of Button too, and its children are the label at rest.