React

Table Pagination

데이터 표의 페이지와 페이지당 표시 행 수를 함께 제어하는 컴포넌트입니다.

사용 가능 버전@seed-design/[email protected], @seed-design/[email protected]

Installation

npx @seed-design/cli@latest add ui:table-pagination

Usage

import { TablePagination } from "seed-design/ui/table-pagination";

전체 데이터 개수를 알면 totalItems를 전달하세요. 현재 범위, 전체 개수, 이동 가능 여부를 컴포넌트가 계산합니다.

Table Pagination은 항상 한 줄로 표시됩니다. 좁은 화면에서는 표와 Table Pagination을 같은 overflow-x: auto 컨테이너 안에 두어 가로 스크롤을 제공하세요.

데이터 표의 아래쪽에서만 사용하세요. 일반 목록의 페이지를 이동할 때는 Pagination을 사용합니다. 기본 페이지당 행 수 옵션은 10개, 25개, 50개이며, 선택지는 3~4개 정도로 유지하는 것을 권장합니다.

Localization

스니펫 파일 상단의 numberFormattertablePaginationText를 앱의 언어에 맞게 수정하세요. 범위, 전체 개수, 페이지당 행 수와 각 컨트롤의 접근성 이름을 한곳에서 바꿀 수 있습니다.

Props

Prop

Type

color?(string & {}) | ScopedColorFg | ScopedColorPalette | undefined
background?(string & {}) | ScopedColorPalette | ScopedColorBg | ScopedColorBanner | undefined
backgroundGradient?"glowMagic" | "glowMagicPressed" | "highlightMagic" | "highlightMagicPressed" | "shimmerMagic" | "shimmerNeutral" | undefined
borderColor?(string & {}) | ScopedColorPalette | ScopedColorStroke | undefined
borderWidth?0 | (string & {}) | 1 | undefined
borderTopWidth?0 | (string & {}) | 1 | undefined
borderRightWidth?0 | (string & {}) | 1 | undefined
borderBottomWidth?0 | (string & {}) | 1 | undefined
borderLeftWidth?0 | (string & {}) | 1 | undefined
borderRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefined
borderTopLeftRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefined
borderTopRightRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefined
borderBottomRightRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefined
borderBottomLeftRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefined
boxShadow?(string & {}) | "s1" | "s2" | "s3" | undefined
width?ResponsiveValue<Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "full"> | undefined
minWidth?ResponsiveValue<Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "full"> | undefined
maxWidth?ResponsiveValue<Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "full"> | undefined
height?ResponsiveValue<Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "full"> | undefined
minHeight?ResponsiveValue<Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "full"> | undefined
maxHeight?ResponsiveValue<Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "full"> | undefined
top?0 | (string & {}) | undefined
left?0 | (string & {}) | undefined
right?0 | (string & {}) | undefined
bottom?0 | (string & {}) | undefined
padding?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {})> | undefined
paddingX?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {})> | undefined
paddingY?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {})> | undefined
paddingTop?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "safeArea"> | undefined
paddingRight?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {})> | undefined
paddingBottom?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "safeArea"> | undefined
paddingLeft?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {})> | undefined
position?"fixed" | "relative" | "absolute" | "sticky" | undefined
overflowX?"hidden" | "auto" | "visible" | "scroll" | undefined
overflowY?"hidden" | "auto" | "visible" | "scroll" | undefined
zIndex?number | (string & {}) | undefined
justifyContent?"flex-start" | "flex-end" | "center" | "space-between" | "space-around" | undefined
alignItems?"flex-start" | "flex-end" | "center" | "stretch" | undefined
alignContent?"flex-start" | "flex-end" | "center" | "stretch" | undefined
alignSelf?"flex-start" | "flex-end" | "center" | "stretch" | undefined
gap?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {})> | undefined
gridColumn?string | undefined
gridRow?string | undefined
unstable_transform?string | undefined
_active?{ bg?: ScopedColorBg | ScopedColorPalette | (string & {}); background?: ScopedColorBg | ScopedColorPalette | (string & {}); } | undefined
asChild?boolean | undefined
hideFrom?BreakpointThreshold | undefined

Examples

Controlled

valuepagepageSize를 하나의 값으로 관리합니다. 페이지당 행 수를 바꾸면 페이지가 1로 초기화되고 onValueChange가 한 번 호출됩니다.

onValueChange Details

onValueChange의 두 번째 인자는 변경 원인을 나타내는 reason과 변경 전 값인 previousValue를 제공합니다.

reason발생 조건
previous이전 페이지 버튼을 선택했을 때
next다음 페이지 버튼을 선택했을 때
page-range표시 범위를 선택했을 때
page-size페이지당 행 수를 바꿨을 때
constraint외부에서 전달한 페이지가 유효 범위를 벗어나 보정됐을 때

외부 페이지가 범위를 벗어나면 보정된 값을 먼저 렌더링하고, 이후 constraint 변경을 한 번 알립니다.

Unknown Total

전체 개수를 아직 알 수 없다면 totalItems를 생략하고 hasPreviousPage, hasNextPage를 전달하세요. 이 모드에서는 현재 범위를 텍스트로 표시하며 전체 개수와 페이지 범위 선택기는 표시하지 않습니다.

currentPageItemCount를 전달하면 마지막 페이지처럼 행 수가 적은 범위를 정확히 표시합니다. 생략하면 pageSize만큼 있다고 가정하며, 일시적으로 pageSize보다 큰 값이 들어오면 pageSize로 보정합니다.

Empty

데이터가 없으면 0-0 / 총 0개를 표시합니다. 페이지 범위 선택기와 이전·다음 버튼은 비활성화되지만 페이지당 행 수는 바꿀 수 있습니다.

Large Data Sets

페이지 수가 200개 이하면 모든 페이지 범위를 자동으로 표시합니다. 200개를 넘으면 첫 페이지, 마지막 페이지, 현재 페이지 주변을 합쳐 최대 200개만 표시합니다.

표시할 페이지를 직접 정하려면 pageOptions를 전달하세요. 전달한 옵션은 모두 렌더링되며 현재 페이지는 옵션에 없더라도 자동으로 포함되므로, 큰 배열은 피하는 것이 좋습니다.

Accessibility

루트는 페이지당 행 수 설정과 페이지 이동을 묶는 group으로 렌더링됩니다. 기본 접근성 이름은 표 페이지 탐색이며, 같은 화면에 표가 여러 개 있으면 aria-label이나 aria-labelledby로 대상을 구분하세요.

페이지를 바꾼 뒤의 로딩 상태와 결과 안내는 Table Pagination이 아니라 연결된 데이터 표 영역에서 제공하세요.

Last updated on

목차