@molecule/app-pagination-bar-solid

Feature · pagination-bar · App (browser) · v1.1.1 · Apache-2.0

Solid PaginationBar with page-window, size-select, and "Showing X of Y" text

npm install @molecule/app-pagination-bar-solid

npm · Source on GitHub

How it works

@molecule/app-pagination-bar-solid is a ready-made pagination-bar feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

import { createSignal } from 'solid-js'
import { PaginationBar } from '@molecule/app-pagination-bar-solid'

function OrderList(props: { total: number }) {
  const [page, setPage] = createSignal(1)
  const [pageSize, setPageSize] = createSignal(10)
  return (
    <PaginationBar
      page={page()}
      totalPages={Math.max(1, Math.ceil(props.total / pageSize()))}
      pageSize={pageSize()}
      total={props.total}
      onPageChange={setPage}
      pageSizeOptions={[10, 25, 50]}
      onPageSizeChange={(size) => {
        setPageSize(size)
        setPage(1)
      }}
    />
  )
}

Works with: @molecule/app-solid, @molecule/app-ui, @molecule/app-ui-solid

Reference

Solid PaginationBar — page-window + "Showing X of Y" text + optional page-size selector.

Built on Button and Select from @molecule/app-ui-solid so it inherits the wired ClassMap styling. Apps drive the i18n noun via the showingKey prop ("Showing 1 to 10 of 123 tags" vs. "…orders") — the key takes start, end, and total interpolation values. It is the Solid counterpart of @molecule/app-pagination-bar-react: the same props (React names) and the same DOM for the same input.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { createSignal } from 'solid-js'
import { PaginationBar } from '@molecule/app-pagination-bar-solid'

function OrderList(props: { total: number }) {
  const [page, setPage] = createSignal(1)
  const [pageSize, setPageSize] = createSignal(10)
  return (
    <PaginationBar
      page={page()}
      totalPages={Math.max(1, Math.ceil(props.total / pageSize()))}
      pageSize={pageSize()}
      total={props.total}
      onPageChange={setPage}
      pageSizeOptions={[10, 25, 50]}
      onPageSizeChange={(size) => {
        setPageSize(size)
        setPage(1)
      }}
    />
  )
}

Type

feature

Installation

npm install @molecule/app-pagination-bar-solid @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js

API

Interfaces

PaginationBarProps

Props accepted by the PaginationBar component.

interface PaginationBarProps {
  /** Current page (1-indexed). */
  page: number
  /** Total page count (>= 1). */
  totalPages: number
  /** Items per page. */
  pageSize: number
  /** Total item count across all pages. */
  total: number
  /** Called when the user changes page. */
  onPageChange: (page: number) => void
  /** Called when the user changes page-size (when allowed via `pageSizeOptions`). */
  onPageSizeChange?: (size: number) => void
  /** Available page-size options. When omitted, the size selector is hidden. */
  pageSizeOptions?: number[]
  /** i18n key for the "Showing X to Y of Z items" text — takes interpolation vars `start`, `end`, `total`. */
  showingKey?: string
  /** Default English fallback for the showing text. */
  showingDefault?: string
  /** Extra classes on the outer wrapper. */
  className?: string
}

Functions

PaginationBar(props)

Paginator with a [showing text, prev, page-window, next, size-select] layout.

The "Showing X to Y of Z items" text is driven by an i18n key so apps can specialize the noun ("tags", "orders", "transactions"). Page-size selector is hidden unless pageSizeOptions + onPageSizeChange are supplied.

This is the Solid counterpart of @molecule/app-pagination-bar-react: the same props (React names) and the same DOM for the same input.

function PaginationBar(props: PaginationBarProps): JSX.Element
  • props — Component props (see PaginationBarProps).

Returns: The rendered pagination bar.

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-solid ^3.5.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-solid ^1.1.0
  • solid-js ^1.8.0

Runtime Dependencies

  • @molecule/app-solid
  • @molecule/app-ui
  • @molecule/app-ui-solid
  • solid-js

Companion locale bond: @molecule/app-locales-pagination-bar (keys pagination.previous, pagination.next, pagination.pageSize, plus your showingKey). The page-size Select is hidden unless BOTH pageSizeOptions and onPageSizeChange are supplied; when shown it wires the Select's typed onValueChange and parses the selected value to a number, so onPageSizeChange always receives a real page size (e.g. 25), never NaN. Requires the Solid binding's i18n provider and a wired ClassMap bond. Distinct from @molecule/app-ui-solid's lower-level Pagination (page window only — no showing-text or size selector).

Translations

Translation strings are provided by @molecule/app-locales-pagination-bar.