Table Pagination
데이터 표의 페이지와 페이지당 표시 행 수를 함께 제어하는 컴포넌트입니다.
Installation
의존성 설치
아래 코드를 복사 후 붙여넣고 사용하세요
Usage
전체 데이터 개수를 알면 totalItems를 전달하세요. 현재 범위, 전체 개수, 이동 가능 여부를 컴포넌트가 계산합니다.
Table Pagination은 항상 한 줄로 표시됩니다. 좁은 화면에서는 표와 Table Pagination을 같은 overflow-x: auto 컨테이너 안에 두어 가로 스크롤을 제공하세요.
데이터 표의 아래쪽에서만 사용하세요. 일반 목록의 페이지를 이동할 때는 Pagination을 사용합니다. 기본 페이지당 행 수 옵션은 10개, 25개, 50개이며, 선택지는 3~4개 정도로 유지하는 것을 권장합니다.
Localization
스니펫 파일 상단의 numberFormatter와 tablePaginationText를 앱의 언어에 맞게 수정하세요. 범위, 전체 개수, 페이지당 행 수와 각 컨트롤의 접근성 이름을 한곳에서 바꿀 수 있습니다.
Props
Prop
Type
color?(string & {}) | ScopedColorFg | ScopedColorPalette | undefinedbackground?(string & {}) | ScopedColorPalette | ScopedColorBg | ScopedColorBanner | undefinedbackgroundGradient?"glowMagic" | "glowMagicPressed" | "highlightMagic" | "highlightMagicPressed" | "shimmerMagic" | "shimmerNeutral" | undefinedborderColor?(string & {}) | ScopedColorPalette | ScopedColorStroke | undefinedborderWidth?0 | (string & {}) | 1 | undefinedborderTopWidth?0 | (string & {}) | 1 | undefinedborderRightWidth?0 | (string & {}) | 1 | undefinedborderBottomWidth?0 | (string & {}) | 1 | undefinedborderLeftWidth?0 | (string & {}) | 1 | undefinedborderRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedborderTopLeftRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedborderTopRightRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedborderBottomRightRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedborderBottomLeftRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedboxShadow?(string & {}) | "s1" | "s2" | "s3" | undefinedwidth?ResponsiveValue<Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "full"> | undefinedminWidth?ResponsiveValue<Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "full"> | undefinedmaxWidth?ResponsiveValue<Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "full"> | undefinedheight?ResponsiveValue<Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "full"> | undefinedminHeight?ResponsiveValue<Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "full"> | undefinedmaxHeight?ResponsiveValue<Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "full"> | undefinedtop?0 | (string & {}) | undefinedleft?0 | (string & {}) | undefinedright?0 | (string & {}) | undefinedbottom?0 | (string & {}) | undefinedpadding?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {})> | undefinedpaddingX?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {})> | undefinedpaddingY?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {})> | undefinedpaddingTop?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "safeArea"> | undefinedpaddingRight?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {})> | undefinedpaddingBottom?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {}) | "safeArea"> | undefinedpaddingLeft?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {})> | undefinedposition?"fixed" | "relative" | "absolute" | "sticky" | undefinedoverflowX?"hidden" | "auto" | "visible" | "scroll" | undefinedoverflowY?"hidden" | "auto" | "visible" | "scroll" | undefinedzIndex?number | (string & {}) | undefinedjustifyContent?"flex-start" | "flex-end" | "center" | "space-between" | "space-around" | undefinedalignItems?"flex-start" | "flex-end" | "center" | "stretch" | undefinedalignContent?"flex-start" | "flex-end" | "center" | "stretch" | undefinedalignSelf?"flex-start" | "flex-end" | "center" | "stretch" | undefinedgap?ResponsiveValue<0 | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | (string & {})> | undefinedgridColumn?string | undefinedgridRow?string | undefinedunstable_transform?string | undefined_active?{ bg?: ScopedColorBg | ScopedColorPalette | (string & {}); background?: ScopedColorBg | ScopedColorPalette | (string & {}); } | undefinedasChild?boolean | undefinedhideFrom?BreakpointThreshold | undefinedExamples
Controlled
value는 page와 pageSize를 하나의 값으로 관리합니다. 페이지당 행 수를 바꾸면 페이지가 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