spst-pagination
実サービスへ通信しない見本です。モデルの描画は静止した代替表示です。
元 commit: d204666f04a0ee7b6f18543f8aec414b4128874e · shadcn build 4.23.1
Noto Sans JP · @fontsource/noto-sans-jp 5.3.1 · OFL-1.1
操作を試す
取り込む(公開予定)
以下の URL は公開予定です。公開前は取り込めません。既存ファイルとの差分を確認してから実行し、--overwrite を既定にしないでください。
npx shadcn@latest add https://spritestack.dev/r/spst-pagination.jsoncomponents.json の registries に追加
{"registries":{"@spritestack":"https://spritestack.dev/r/{name}.json"}}npx shadcn@latest add @spritestack/spst-paginationReact 19・Tailwind v4・shadcn の src/ を持つ構成が対象です。src/ の無い構成は未検証です。取り込みはソースのコピーで、自動更新されません。
import "./styles/spritestack/theme.css";
<div className="spst-theme" data-theme="light">
{/* Render components here. */}
</div>Portal の container / portalContainer は .spst-theme 内の要素を渡してください。Noto Sans JP の 400・600・700 は利用先が自己ホストしてください。未導入時は system-ui です。
依存
lucide-react@1.84.0react@19.2.4- spst-button
- spst-theme
- spst-utils
Props / API
以下は実際のソースを構文解析して生成しています。… の行は継承する React / Radix の公開型です。既定欄の — は、この関数の引数で既定を指定していないことを表します。union の必須条件は型宣言も確認してください。
src/components/ui/pagination.tsx
Pagination
Pagination({ messages, className, ...props }: React.ComponentProps<"nav"> & MessageProps)| Prop | 型 | 必須 | 既定 | イベント |
|---|---|---|---|---|
… | React.ComponentProps<"nav"> | — | — | — |
messages | Partial<PaginationMessages> | いいえ | — | — |
PaginationContent
PaginationContent({ className, ...props }: React.ComponentProps<"ul">)| Prop | 型 | 必須 | 既定 | イベント |
|---|---|---|---|---|
… | React.ComponentProps<"ul"> | — | — | — |
PaginationItem
PaginationItem(props: React.ComponentProps<"li">)| Prop | 型 | 必須 | 既定 | イベント |
|---|---|---|---|---|
… | React.ComponentProps<"li"> | — | — | — |
PaginationLink
PaginationLink({
className,
isActive,
disabled,
href,
onClick,
onAuxClick,
tabIndex,
...props
}: PaginationLinkProps)| Prop | 型 | 必須 | 既定 | イベント |
|---|---|---|---|---|
… | React.ComponentProps<"a"> | — | — | — |
isActive | boolean | いいえ | — | — |
disabled | boolean | いいえ | — | — |
PaginationPrevious
PaginationPrevious({ messages, children, ...props }: PaginationLinkProps & MessageProps)| Prop | 型 | 必須 | 既定 | イベント |
|---|---|---|---|---|
… | React.ComponentProps<"a"> | — | — | — |
isActive | boolean | いいえ | — | — |
disabled | boolean | いいえ | — | — |
messages | Partial<PaginationMessages> | いいえ | — | — |
PaginationNext
PaginationNext({ messages, children, ...props }: PaginationLinkProps & MessageProps)| Prop | 型 | 必須 | 既定 | イベント |
|---|---|---|---|---|
… | React.ComponentProps<"a"> | — | — | — |
isActive | boolean | いいえ | — | — |
disabled | boolean | いいえ | — | — |
messages | Partial<PaginationMessages> | いいえ | — | — |
PaginationEllipsis
PaginationEllipsis({
messages,
children,
className,
...props
}: React.ComponentProps<"span"> & MessageProps)| Prop | 型 | 必須 | 既定 | イベント |
|---|---|---|---|---|
… | React.ComponentProps<"span"> | — | — | — |
messages | Partial<PaginationMessages> | いいえ | — | — |
型宣言とソースを確認
// 出典: shadcn/ui new-york-v4/pagination(commit c1ead5c92572ce6e95dc7bb3221feaf2b3aa59a7、MIT)。
"use client";
import { ChevronLeftIcon, ChevronRightIcon, MoreHorizontalIcon } from "lucide-react";
import type * as React from "react";
import { cn } from "../../lib/spritestack/utils";
import { buttonVariants } from "./button";
export type PaginationMessages = {
label: string;
previous: string;
next: string;
ellipsis: string;
};
const defaultMessages: PaginationMessages = {
label: "ページ切り替え",
previous: "前へ",
next: "次へ",
ellipsis: "ページを省略",
};
type MessageProps = { messages?: Partial<PaginationMessages> };
function Pagination({ messages, className, ...props }: React.ComponentProps<"nav"> & MessageProps) {
const m = { ...defaultMessages, ...messages };
return (
<nav
aria-label={m.label}
data-slot="pagination"
className={cn("mx-auto flex w-full justify-center", className)}
{...props}
/>
);
}
function PaginationContent({ className, ...props }: React.ComponentProps<"ul">) {
return (
<ul
data-slot="pagination-content"
className={cn("flex flex-wrap items-center gap-1", className)}
{...props}
/>
);
}
function PaginationItem(props: React.ComponentProps<"li">) {
return <li data-slot="pagination-item" {...props} />;
}
type PaginationLinkProps = React.ComponentProps<"a"> & { isActive?: boolean; disabled?: boolean };
function PaginationLink({
className,
isActive,
disabled,
href,
onClick,
onAuxClick,
tabIndex,
...props
}: PaginationLinkProps) {
return (
<a
{...props}
data-slot="pagination-link"
// biome-ignore lint/a11y/noRedundantRoles: disabled のとき href を外してもリンクの意味を保持する。
role="link"
aria-current={isActive ? "page" : undefined}
aria-disabled={disabled || undefined}
href={disabled ? undefined : href}
tabIndex={disabled ? -1 : tabIndex}
onClick={(event) => {
if (disabled) {
event.preventDefault();
return;
}
onClick?.(event);
}}
onAuxClick={(event) => {
if (disabled) {
event.preventDefault();
return;
}
onAuxClick?.(event);
}}
className={cn(
buttonVariants({ variant: "outline" }),
"aria-disabled:cursor-not-allowed not-aria-disabled:hover:bg-accent",
isActive && "bg-accent inset-ring inset-ring-ring",
className,
)}
/>
);
}
function PaginationPrevious({ messages, children, ...props }: PaginationLinkProps & MessageProps) {
const m = { ...defaultMessages, ...messages };
return (
<PaginationLink aria-label={m.previous} {...props}>
<ChevronLeftIcon aria-hidden="true" className="size-4" />
{children ?? m.previous}
</PaginationLink>
);
}
function PaginationNext({ messages, children, ...props }: PaginationLinkProps & MessageProps) {
const m = { ...defaultMessages, ...messages };
return (
<PaginationLink aria-label={m.next} {...props}>
{children ?? m.next}
<ChevronRightIcon aria-hidden="true" className="size-4" />
</PaginationLink>
);
}
function PaginationEllipsis({
messages,
children,
className,
...props
}: React.ComponentProps<"span"> & MessageProps) {
const m = { ...defaultMessages, ...messages };
return (
<span
data-slot="pagination-ellipsis"
className={cn("flex items-center justify-center p-2 text-foreground", className)}
{...props}
>
<MoreHorizontalIcon aria-hidden="true" className="size-4" />
<span className="sr-only">{children ?? m.ellipsis}</span>
</span>
);
}
export {
Pagination,
PaginationContent,
PaginationEllipsis,
PaginationItem,
PaginationLink,
PaginationNext,
PaginationPrevious,
};
アクセシビリティの利用条件
- 入力には Label または読み上げ名を与え、エラーを aria-describedby で関連づけます。色だけで状態を伝えません。
- 画像にはモデル名と代替表示を与えます。単独アイコンのボタンにも名前が必要です。
- Dialog / Sheet に題名と説明を与え、Portal をテーマ内に置きます。Tab・矢印・Escape と閉じた後のフォーカスを利用先でも確認します。
- Slider は名前と有限の min < max、ToggleGroup は空でない single の値が必要です。pending は親が制御します。
対応画像: 09 · 暗色とエラーは設計による補完です。