Load More
ProNewThe end of a growing list: a count, a bar showing how much is loaded and a button, with optional loading on scroll.
Installation
pnpm dlx shadcn@latest add @viewport/load-more
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| shown* | numberHow many items are shown now, and how many there are in all. | — |
| total* | number | — |
| onLoadMore* | () => voidRuns when more items are wanted. | — |
| loading | boolean | false |
| auto | booleanLoad the next page when the control scrolls into view, instead of waiting for a press. The button stays, as a fallback. | false |
| noun | stringWhat the items are, e.g. "contacts". | "results" |
| className | string | — |
Accessibility
- The button remains when loading on scroll is on, so there is always a manual way.
- The count is announced when more rows arrive.
- The button stays focusable while it loads.