Skip to content
synccn

Load More

New

Button for long lists with loading and end states.

  • Changelog entry 14
  • Changelog entry 13
  • Changelog entry 12
  • Changelog entry 11

Installation

$ pnpm dlx shadcn@latest add @synccn/load-more

First time in this project? Connect synccn with one command.

Usage

import { LoadMore } from "@/components/ui/nav-extras";<LoadMore onLoad={fetchNext} hasMore={hasMore} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

LoadMore

"Load more" button for long lists, with a loading state and an end-of-list message.

  • onLoad
    () => void | Promise<void>

    Loads the next page. Return a promise to show the loading state.

  • hasMore
    boolean

    Default true

    False shows the end-of-list message.

  • loadingLabel
    string

    Default "Loading…"

    Button text while loading.

  • doneLabel
    string

    Default "You've reached the end"

    Message when there's nothing left.

  • children
    React.ReactNode

    Default "Load more"

    Content to render.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/utilscn (merges class names)
  • lib/hooksuseClickOutside (closes on an outside click), useEscape (closes on Escape)

npm packages

Accessibility

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA attributes: aria-current, aria-expanded, aria-hidden, aria-label
  • Closes with Escape
  • Closes when you click or tap outside