Pagination
結果のページ間を移動するリンクまたはボタン。
- ブラウザー
- Chrome 123+Firefox 121+Safari 17.5+
- ティア
- 0
- 圧縮後のサイズ
- 2.59 kB
- 強制レイアウトの上限
- 0 ms
- axe の上限
- 0
- SSR 対応
- はい
- 公開された契約
- テストハーネス
プレイグラウンド
Pagination
import { Pagination } from "@gunkin/uiify";
export default function Example() {
return (
<Pagination.Root className="" count={20} defaultPage={5}>
<Pagination.List />
</Pagination.Root>
);
}@layer components {
[data-uiify-pagination] ol {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
gap: 0.25rem;
list-style: none;
padding: 0;
margin: 0;
}
[data-uiify-pagination] li {
display: grid;
place-items: center;
}
/* Page links and the previous/next controls are Button-skinned (`ghost`); the current
page is the selected one. Links stay links, so only the pointer is restored here. */
[data-uiify-pagination] [data-type="ellipsis"] {
display: inline-grid;
place-items: center;
min-inline-size: 2.75rem;
color: var(--muted-foreground);
}
[data-uiify-pagination] span[data-uiify-button]:not([data-disabled]) {
cursor: default;
}
[data-uiify-pagination] svg {
inline-size: 1rem;
block-size: 1rem;
}
}import { Pagination } from "@gunkin/uiify";
export default function Example() {
return (
<Pagination.Root
className="
[&_ol]:flex [&_ol]:flex-wrap [&_ol]:items-center [&_ol]:justify-center [&_ol]:[gap:0.25rem] [&_ol]:list-none
[&_ol]:p-0 [&_ol]:m-0 [&_li]:grid [&_li]:place-items-center [&_[data-type=ellipsis]]:inline-grid
[&_[data-type=ellipsis]]:place-items-center [&_[data-type=ellipsis]]:[min-inline-size:2.75rem]
[&_[data-type=ellipsis]]:text-muted-foreground [&_span[data-uiify-button]:not([data-disabled])]:cursor-default
[&_svg]:[inline-size:1rem] [&_svg]:[block-size:1rem]
"
count={20}
defaultPage={5}
>
<Pagination.List />
</Pagination.Root>
);
}/* app.css */
@layer reset, ui, app, tokens, base, demo, components, utilities, theme;
@import "@gunkin/uiify/styles/reset";
@import "@gunkin/uiify/components/behavior.css";
@import "@gunkin/uiify/styles/tokens";
@import "@gunkin/uiify/styles/tailwind";
@import "tailwindcss/utilities.css";
@theme { --spacing: 0.25rem; --font-weight-normal: 400; --font-weight-medium: 500; --font-weight-semibold: 600; --font-weight-bold: 700; }
@source inline('[&_ol]:flex [&_ol]:flex-wrap [&_ol]:items-center [&_ol]:justify-center [&_ol]:[gap:0.25rem] [&_ol]:list-none [&_ol]:p-0 [&_ol]:m-0 [&_li]:grid [&_li]:place-items-center [&_[data-type=ellipsis]]:inline-grid [&_[data-type=ellipsis]]:place-items-center [&_[data-type=ellipsis]]:[min-inline-size:2.75rem] [&_[data-type=ellipsis]]:text-muted-foreground [&_span[data-uiify-button]:not([data-disabled])]:cursor-default [&_svg]:[inline-size:1rem] [&_svg]:[block-size:1rem]');
@layer base { :root { --uiify-control-text: var(--text-sm); } @media (pointer: coarse) { :root { --uiify-control-text: var(--text-base); } } }
/* Authored animation and registered properties used by the Tailwind skin.
* Visual rules belong in utility recipes; only at-rule definitions live here. */
@layer components {
@keyframes uiify-presence-in {
from {
opacity: 0;
scale: var(--presence-scale);
}
}
}
@layer components {
@keyframes uiify-presence-out {
to {
opacity: 0;
scale: var(--presence-scale);
}
}
}
@property --uiify-spinner-tail {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
@property --uiify-spinner-length {
syntax: "<angle>";
inherits: false;
initial-value: 36deg;
}
@layer components {
@keyframes uiify-spinner-rotate {
to {
transform: rotate(360deg);
}
}
}
@layer components {
@keyframes uiify-spinner-orbit {
0% {
--uiify-spinner-tail: 0deg;
--uiify-spinner-length: 36deg;
}
50% {
--uiify-spinner-tail: 90deg;
--uiify-spinner-length: 324deg;
}
100% {
--uiify-spinner-tail: 360deg;
--uiify-spinner-length: 36deg;
}
}
}
@layer components {
@keyframes uiify-skeleton-pulse {
50% {
opacity: 0.45;
}
}
}
@layer components {
@keyframes uiify-skeleton-shimmer {
to {
background-position: -200% 0;
}
}
}
@layer components {
@keyframes uiify-skeleton-reveal {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
}
@property --candle-body-height {
syntax: "<percentage>";
inherits: true;
initial-value: 0%;
}
@property --candle-body-top {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --candle-slot {
syntax: "<percentage>";
inherits: true;
initial-value: 100%;
}
@property --candle-wick-height {
syntax: "<percentage>";
inherits: true;
initial-value: 0%;
}
@property --candle-wick-top {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --candle-x {
syntax: "<percentage>";
inherits: true;
initial-value: 0%;
}
@property --candle-scale {
syntax: "<number>";
inherits: true;
initial-value: 1;
}
@property --line-y {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --line-prev-y {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --line-count {
syntax: "<integer>";
inherits: false;
initial-value: 1;
}
@property --line-scale {
syntax: "<number>";
inherits: true;
initial-value: 1;
}
@layer components {
@keyframes uiify-otp-input-caret-blink {
50% {
opacity: 0;
}
}
}API
Pagination.Root
| Prop | 型 | 既定値 | 説明 |
|---|---|---|---|
aria-label | string | "Pagination" | ナビゲーションランドマークのアクセシブルな名前。 |
boundaryCount | number | 1 | 範囲の両端に常に表示するページ数。 |
count* | number | — | 総ページ数。 |
defaultPage | number | 1 | コンポーネントが非制御の場合の初期選択ページ。 |
disabled | boolean | false | すべてのページとナビゲーションコントロールを無効にします。 |
onPageChange | (page: number) => void | — | ページが変わるたび、新しいページ番号で呼び出します。 |
page | number | — | 現在のページ。コンポーネントを制御します。 |
showFirstLast | boolean | false | 生成する項目に、最初と最後のページへのコントロールを追加します。 |
siblingCount | number | 1 | 現在のページの前後に表示するページ数。 |
children | ReactNode | — | 独自の項目マークアップ。省略すると生成したページ一覧を描画します。 |
getPageHref | (page: number) => string | — | 各ページのhrefを作ります。サーバーシェルはJavaScriptなしで動作する実際のリンクを描画します。 |
render | ReactElement | ((props, state) => ReactElement) | — | 動作とアクセシビリティの接続を維持したまま、描画する要素を置き換えます。 |
Pagination.List
| Prop | 型 | 既定値 | 説明 |
|---|---|---|---|
children | ReactNode | — | リスト内に描画するページネーションの項目。 |
render | ReactElement | ((props, state) => ReactElement) | — | 動作とアクセシビリティの接続を維持したまま、描画する要素を置き換えます。 |
Pagination.Item
| Prop | 型 | 既定値 | 説明 |
|---|---|---|---|
children | ReactNode | — | ページネーションの1項目の内容。 |
render | ReactElement | ((props, state) => ReactElement) | — | 動作とアクセシビリティの接続を維持したまま、描画する要素を置き換えます。 |
Pagination.Link
| Prop | 型 | 既定値 | 説明 |
|---|---|---|---|
disabled | boolean | false | コントロールを無効にし、hrefを除去します。 |
getPageHref | (page: number) => string | — | このページのhrefを作り、コントロールを実際のリンクにします。 |
page* | number | — | このコントロールが選択するページ番号。 |
selected | boolean | false | このページを現在のページとして示し、aria-currentを設定します。 |
render | ReactElement | ((props, state) => ReactElement) | — | 動作とアクセシビリティの接続を維持したまま、描画する要素を置き換えます。 |
Pagination.Ellipsis
| Prop | 型 | 既定値 | 説明 |
|---|---|---|---|
children | ReactNode | — | 支援技術から隠す省略記号の内容。 |
render | ReactElement | ((props, state) => ReactElement) | — | 動作とアクセシビリティの接続を維持したまま、描画する要素を置き換えます。 |
キーボード
| キー | 操作 |
|---|---|
| Tab | コントロールへ、またはコントロールからフォーカスを移動 |
| Enter / Space | フォーカス時に実行(ボタン型のコントロール) |
アクセシビリティ
可能な限りセマンティックHTMLを使います。プレイグラウンドで描画されたマークアップを確認できます。ARIAはネイティブ要素だけでは足りない場合にのみ追加します。
スタイリングのフック
data-disabled