生态产品多个设计器现已发布候选版本

查看生态总览
Skip to content

Pagination ​

Navigation component. This page is the API reference, generated from the source code. Usage guidance and live examples are on the Chinese page.

Anatomy ​

Parts in bold are required.

data-scope="pagination": root · summary · jumper · first-trigger · prev-trigger · next-trigger · last-trigger · item · ellipsis-trigger · page-size-select · positioner · content

API reference ​

Descriptions of individual props, events and slots are written in Chinese and appear on the Chinese page.

Artifacts ​

LayerValue
Custom element<xh-pagination>
Vue componentsXhPaginationContent XhPaginationEllipsisTrigger XhPaginationFirstTrigger XhPaginationItem XhPaginationJumper XhPaginationLastTrigger XhPaginationNextTrigger XhPaginationPageSizeSelect XhPaginationPositioner XhPaginationPrevTrigger XhPaginationRoot XhPaginationSummary
ComposableusePagination
State machinepaginationMachine
Skin@xihan-ui/styles/pagination.css

Props ​

PropTypeRequired
countnumber
pageSizenumber
defaultPageSizenumber
pageSizeOptionsnumber[]
pagenumber
defaultPagenumber
siblingCountnumber
disabledboolean
dirDirection
translationsPartial<PaginationTranslations>
placementPlacement
offsetnumber
openDelaynumber
closeDelaynumber
toneTone
sizeSize
onPageChange(details: PaginationPageChangeDetails) => void
onPageSizeChange(details: PaginationPageSizeChangeDetails) => void

Events ​

Custom elements put the payload in detail; Vue emits an event of the same name.

EventPayload
page-changePaginationPageChangeDetails
page-size-change``

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhPaginationContentdefault{ pages: number[] }
XhPaginationRootdefaultPaginationRootSlotProps
XhPaginationSummarydefault{ summaryText: string, start: number, end: number, count: number }

React adapter props ​

Only the props each component declares itself: DOM attributes inherited from ComponentPropsWithRef are left out, and root props already listed in the Props table are not repeated. The Vue counterpart is the slot table above.

React componentPropTypeRequired
XhPaginationContentchildrenSlotChildren<PaginationContentSlotProps>
XhPaginationEllipsisTriggersidePaginationEllipsisSide
XhPaginationItemvaluenumber | stringYes
XhPaginationPageSizeSelectcontainer() => Element | null
XhPaginationPositionercontainer() => Element | null
XhPaginationRootchildrenSlotChildren<PaginationRootSlotProps>
XhPaginationSummarychildrenSlotChildren<PaginationSummarySlotProps>

State ​

Public state is written to data-state.

PartValues
ellipsis-trigger'open' | 'closed'
positioner'open' | 'closed'
content'open' | 'closed'

The following names are internal to the state machine.

States: closed · opening · visible · visible.open · visible.closing

Events: PAGE.SET · PAGE_SIZE.SET · PAGE.PREV · PAGE.NEXT · ELLIPSIS.ENTER · ELLIPSIS.LEAVE · ELLIPSIS.TOGGLE · ELLIPSIS.CLOSE · after.openDelay · after.closeDelay · PRESS.START · PRESS.END

Guards: isSameEllipsis · canPress · isEnabled

connect API ​

getXxxProps() returns the host attributes of the matching part.

MemberType
pagenumber
pageSizenumber
pageSizeOptionsnumber[]
countnumber
totalPagesnumber
pagesPaginationPage[]
pageItemsPaginationPageItem[]
openEllipsisPaginationEllipsisSide | null
disabledboolean
pageRangePaginationEntryRange
summaryTextstring
previousPagenumber | null
nextPagenumber | null
setPage(page: number) => void
goToPrevPage() => void
goToNextPage() => void
setPageSize(pageSize: number) => void
slice<V>(data: readonly V[]) => V[]
getRootProps() => T['element']
getSummaryProps() => T['element']
getJumperProps() => T['input']
getFirstTriggerProps() => T['button']
getPrevTriggerProps() => T['button']
getNextTriggerProps() => T['button']
getLastTriggerProps() => T['button']
getItemProps(props: PaginationItemProps) => T['button']
getEllipsisTriggerProps(props: PaginationEllipsisTriggerProps) => T['button']
getPageSizeSelectProps() => T['element']
pageSizeSelectSelectApi<T>
getPositionerProps() => T['element']
getContentProps() => T['element']
closeEllipsis() => void

Accessibility ​

Keyboard ​

Specification: W3C APG. Each row is a stable behavior id that the conformance tests cover; the conditions and effects are described on the Chinese page.

KeysBehavior
Enter / Spacepagination.kbd.item
Enter / Spacepagination.kbd.first
Enter / Spacepagination.kbd.prev
Enter / Spacepagination.kbd.next
Enter / Spacepagination.kbd.last
Enter / Spacepagination.kbd.ellipsis
Enter / Spacepagination.kbd.press
Escapepagination.kbd.ellipsis-escape
Tab / Shift+Tabpagination.kbd.tab

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-labellabel.root
jumperaria-labellabel.jumper
first-triggeraria-labellabel.firstTrigger
prev-triggeraria-labellabel.prevTrigger
next-triggeraria-labellabel.nextTrigger
last-triggeraria-labellabel.lastTrigger
itemaria-current'page' | undefined
itemaria-labellabel.item(item.page)
ellipsis-triggeraria-controlsid of the content part | undefined
ellipsis-triggeraria-expanded'true' | 'false'
ellipsis-triggeraria-haspopup'true'
ellipsis-triggeraria-labellabel.ellipsis( (items.find(item => item.type === 'el…
contentaria-hidden!open || undefined
contentaria-labellabel.ellipsis(folded.length)
contentrole'group'

Style reference ​

Skin ​

@xihan-ui/styles/pagination.css is written against [data-scope="pagination"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-pagination in place of data-scope (same specificity) and sits in the xihan.components layer. Put overrides in xihan.overrides; the part selectors work as usual.

Data attributes ​

Produced by connect; valueless attributes are omitted while their condition does not hold.

PartAttributeValue
rootdata-disabled'' (present only while the condition holds)
rootdata-empty'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-toneprops.tone
summarydata-empty'' (present only while the condition holds)
jumperdata-disabled'' (present only while the condition holds)
jumperdata-empty'' (present only while the condition holds)
jumperdata-variant'outline'
jumperdata-xh-field-chrome''
jumperdata-xh-field-sizeprops.size
first-triggerdata-disabled'' (present only while the condition holds)
first-triggerdata-pressed'' (present only while the condition holds)
first-triggerdata-xh-action-control''
first-triggerdata-xh-action-display'always'
first-triggerdata-xh-action-profile'text'
first-triggerdata-xh-action-sizeprops.size
first-triggerdata-xh-action-variant'ghost'
prev-triggerdata-disabled'' (present only while the condition holds)
prev-triggerdata-pressed'' (present only while the condition holds)
prev-triggerdata-xh-action-control''
prev-triggerdata-xh-action-display'always'
prev-triggerdata-xh-action-profile'text'
prev-triggerdata-xh-action-sizeprops.size
prev-triggerdata-xh-action-variant'ghost'
next-triggerdata-disabled'' (present only while the condition holds)
next-triggerdata-pressed'' (present only while the condition holds)
next-triggerdata-xh-action-control''
next-triggerdata-xh-action-display'always'
next-triggerdata-xh-action-profile'text'
next-triggerdata-xh-action-sizeprops.size
next-triggerdata-xh-action-variant'ghost'
last-triggerdata-disabled'' (present only while the condition holds)
last-triggerdata-pressed'' (present only while the condition holds)
last-triggerdata-xh-action-control''
last-triggerdata-xh-action-display'always'
last-triggerdata-xh-action-profile'text'
last-triggerdata-xh-action-sizeprops.size
last-triggerdata-xh-action-variant'ghost'
itemdata-current'' (present only while the condition holds)
itemdata-disabled'' (present only while the condition holds)
itemdata-pressed'' (present only while the condition holds)
itemdata-xh-action-control''
itemdata-xh-action-display'always'
itemdata-xh-action-profile'text'
itemdata-xh-action-sizeprops.size
itemdata-xh-action-variant'ghost'
ellipsis-triggerdata-disabled'' (present only while the condition holds)
ellipsis-triggerdata-pressed'' (present only while the condition holds)
ellipsis-triggerdata-sideprops.side
ellipsis-triggerdata-state'open' | 'closed'
ellipsis-triggerdata-xh-action-control''
ellipsis-triggerdata-xh-action-display'always'
ellipsis-triggerdata-xh-action-profile'text'
ellipsis-triggerdata-xh-action-sizeprops.size
ellipsis-triggerdata-xh-action-variant'ghost'
page-size-selectdata-empty'' (present only while the condition holds)
positionerdata-hidden'' (present only while the condition holds)
positionerdata-placementactual placement computed by the positioning engine
positionerdata-positioned'' (present only while the condition holds)
positionerdata-sizeprops.size
positionerdata-state'open' | 'closed'
positionerdata-toneprops.tone
contentdata-placementactual placement computed by the positioning engine
contentdata-sizeprops.size
contentdata-state'open' | 'closed'

CSS variables ​

The public override slots, generated from what the standalone skin actually consumes.

VariablePartCSS propertyStateDefault from
--xh-pagination-content-bgcontentbackgrounddefault--xh-bg-surface
--xh-pagination-content-bordercontentborderdefault--xh-border-default
--xh-pagination-content-max-hcontentmax-block-sizedefault--xh-overlay-max-h
--xh-pagination-content-max-wcontentmax-inline-sizedefault--xh-overlay-max-w
--xh-pagination-content-pcontentpaddingdefault--xh-space-1
--xh-pagination-content-radiuscontentborder-radiusdefault--xh-shape-overlay
--xh-pagination-content-shadowcontentbox-shadowdefault--xh-elevation-floating
--xh-pagination-ellipsis-trigger-fgellipsis-triggercolordefault
disabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-fg-subtle
--xh-pagination-font-sizeellipsis-trigger
first-trigger
item
jumper
last-trigger
next-trigger
prev-trigger
summary
font-sizedefault--xh-_pagination-font-size
--xh-pagination-gapcontent
root
gapdefault--xh-space-1
--xh-pagination-icon-sizeellipsis-trigger
first-trigger
item
last-trigger
next-trigger
positioner
prev-trigger
root
--xh-icon-sizedefault
is([data-part='root'], [data-part='positioner'])
size=lg
size=sm
--xh-_action-profile-glyph-size
--xh-glyph-size-lg
--xh-glyph-size-md
--xh-glyph-size-sm
--xh-pagination-item-bgellipsis-trigger
first-trigger
item
last-trigger
next-trigger
prev-trigger
--xh-ink-surface
background-color
default
xh-ink-surface
--xh-_action-variant-bg-rest
--xh-pagination-item-bg-activeellipsis-trigger
first-trigger
item
last-trigger
next-trigger
prev-trigger
background-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-pagination-item-bg-hoverellipsis-trigger
first-trigger
item
last-trigger
next-trigger
prev-trigger
background-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-pagination-item-bg-selecteditem--xh-ink-surface
background-color
current
focus-visible
xh-ink-surface
--xh-_pagination-selected-bg
--xh-pagination-item-bg-selected-activeitembackground-colorcurrent
disabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_pagination-selected-bg-active
--xh-pagination-item-bg-selected-hoveritembackground-colorcurrent
disabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_pagination-selected-bg-hover
--xh-pagination-item-borderellipsis-trigger
first-trigger
item
last-trigger
next-trigger
prev-trigger
border
border-color
default
disabled
focus-visible
--xh-border-default
--xh-pagination-item-border-hoverellipsis-trigger
first-trigger
item
last-trigger
next-trigger
prev-trigger
border-colordisabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-border-strong
--xh-pagination-item-border-selecteditemborder
border-color
current
focus-visible
--xh-_pagination-selected-border
--xh-pagination-item-border-selected-activeitemborder-colorcurrent
disabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_pagination-selected-border
--xh-pagination-item-border-selected-hoveritemborder-colorcurrent
disabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_pagination-selected-border
--xh-pagination-item-fgellipsis-trigger
first-trigger
item
jumper
last-trigger
next-trigger
prev-trigger
colordefault
disabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
xh-field-chrome
--xh-_action-variant-fg-rest
--xh-fg-default
--xh-pagination-item-fg-selecteditemcolorcurrent
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_pagination-selected-fg
--xh-pagination-item-font-weightellipsis-trigger
first-trigger
item
last-trigger
next-trigger
prev-trigger
font-weightdefault--xh-text-label-weight
--xh-pagination-item-hellipsis-trigger
first-trigger
item
jumper
last-trigger
next-trigger
prev-trigger
summary
block-size
min-block-size
default
has([data-xh-field-input][data-xh-field-layout='multi-tag'])
has([data-xh-field-input][data-xh-field-layout='single-line'])
has([data-xh-field-input][data-xh-field-layout='textarea'])
xh-field-chrome
xh-field-input
xh-field-layout=multi-tag
xh-field-layout=single-line
xh-field-layout=textarea
--xh-_pagination-item-size
--xh-pagination-item-min-sizeellipsis-trigger
first-trigger
item
last-trigger
next-trigger
prev-trigger
min-inline-sizedefault--xh-_pagination-item-size
--xh-pagination-item-pxellipsis-trigger
first-trigger
item
jumper
last-trigger
next-trigger
prev-trigger
padding-inlinedefault
xh-field-chrome
--xh-_pagination-item-px
--xh-_pagination-jumper-px
--xh-pagination-item-radiusellipsis-trigger
first-trigger
item
jumper
last-trigger
next-trigger
prev-trigger
border-radiusdefault
xh-field-chrome
--xh-shape-control
--xh-shape-surface
--xh-pagination-item-shadowitembox-shadowcurrent
disabled
focus-visible
hover
is(:active, [data-pressed])
is(:hover, [data-loading])
loading
not([data-disabled])
not([data-loading])
pressed
none
--xh-pagination-jumper-bgjumperbackground-colorxh-field-chrome--xh-_field-variant-bg-rest
--xh-pagination-jumper-bg-disabledjumperbackground-colordisabled
xh-field-chrome
--xh-_field-variant-bg-disabled
--xh-pagination-jumper-bg-hoverjumperbackground-colordisabled
hover
invalid
loading
not(:focus-within)
not([data-disabled])
not([data-invalid])
not([data-loading])
not([data-readonly])
readonly
xh-field-chrome
--xh-_field-variant-bg-hover
--xh-pagination-jumper-borderjumperborderxh-field-chrome--xh-_field-variant-border-rest
--xh-pagination-jumper-border-focusjumperborder-color
box-shadow
disabled
focus-within
not([data-disabled])
xh-field-chrome
--xh-_field-variant-border-focus
--xh-pagination-jumper-border-hoverjumperborder-colordisabled
hover
invalid
loading
not(:focus-within)
not([data-disabled])
not([data-invalid])
not([data-loading])
not([data-readonly])
readonly
xh-field-chrome
--xh-_field-variant-border-hover
--xh-pagination-jumper-border-invalidjumperborder-colorinvalid
user-invalid
xh-field-chrome
--xh-_field-variant-border-invalid
--xh-pagination-jumper-wjumperinline-sizedefault--xh-space-8
--xh-pagination-layerpositionerz-indexdefault--xh-_layer
--xh-pagination-page-size-select-wpage-size-select--xh-select-control-wdefaultmax-content
--xh-pagination-summary-fgsummarycolordefault--xh-fg-muted

Released under The MIT License