Skip to main content

Pagination

Used to paginate content when there is too much data, with controlled / uncontrolled modes, page-size switching, and a jump input.

Basic usage​

Basic usage
import { useState } from 'react'
import { LhPagination } from '@lh-ui/react'

export default function Demo() {
const [current, setCurrent] = useState(1)

return (
<LhPagination
total={128}
current={current}
onChange={(page) => setCurrent(page)}
/>
)
}

Pagination Props​

PropDescriptionTypeOptionsDefault
totalTotal number of records (required)number——
currentCurrent page (controlled, 1-based)number——
defaultCurrentDefault current page (uncontrolled)number—1
pageSizePage size (controlled)number——
defaultPageSizeDefault page size (uncontrolled)number—10
pageSizesPage size optionsnumber[]—[10, 20, 30, 40]
siblingCountNumber of page numbers shown on each side of the current pagenumber—1
showTotalWhether to show the total countboolean—false
showSizeChangerWhether to show the page-size switcherboolean—false
showJumperWhether to show the jump inputboolean—false
simpleCompact modeboolean—false
disabledWhether to disableboolean—false
sxShorthand layout propsSxProps——

Pagination events​

EventDescriptionCallback signatureVue equivalent
onChangeEmitted when the page changes (page switch, jump, or clamping caused by a page-size change all trigger it)(current: number, pageSize: number) => void@change
onSizeChangeEmitted when the page size changes(pageSize: number) => void@size-change
Controlled / uncontrolled

Passing current makes the component controlled (no internal state, driven externally); passing defaultCurrent uses the internal uncontrolled state. The same applies to pageSize. onChange fires in both modes.

Page clamping

When a page-size change shrinks the total page count and the current page falls out of range, the component automatically clamps it to the last page in an effect and emits onChange — no fallback needed on the business side.

Keyboard interaction​

Jump input: Enter submits the jump, and blur submits as well; invalid values (out of range or non-numeric) are clamped to the valid range.

Accessibility​

The root element is <nav aria-label>; the current page emits aria-current="page", and each page button carries an aria-label (locale pack pagination.page template, e.g. "Page 3").

ref​

forwardRef<HTMLElement> — the <nav> root element.

Styles​

import '@lh-ui/react/theme.css'
import '@lh-ui/react/style/pagination'