Skip to Content
zjkm-ui
Components

Load More

A button that loads the next page and shows the count.

Showing 20 of 84 results

Props
<LoadMore shown={shown} total={84} onLoadMore={loadMore} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/load-more.json
import { LoadMore } from "@/components/load-more"

Using JavaScript? Set tsx: false in components.json and the CLI converts it.

New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.

Usage

"Showing 20 of 84 results" with a progress bar and a Load more button, which goes away once everything is shown. The count is announced when it changes.

import { LoadMore } from "@/components/load-more";

export function Results({ items, total, loadMore, loading }: Props) {
  return <LoadMore shown={items.length} total={total} loading={loading} onLoadMore={loadMore} />;
}

Props

PropTypeDefaultDescription
shownnumberHow many are shown.
totalnumberHow many there are.
loadingbooleanfalseShows Loading… and disables the button.
onLoadMore() => voidCalled on click.
nounstring"results"What's being listed.
classNamestringClasses for the root element.

With reduced motion, the bar fills without animating.

On this page