跳至正文
uiify

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

属性类型默认值说明
aria-labelstring"Pagination"导航地标的无障碍名称。
boundaryCountnumber1范围两端始终显示的页数。
count*number—总页数。
defaultPagenumber1组件非受控时初始选中的页。
disabledbooleanfalse禁用所有页面和导航控件。
onPageChange(page: number) => void—页面变化时,使用新页码调用。
pagenumber—当前页,使组件受控。
showFirstLastbooleanfalse为生成的项目添加首页和末页控件。
siblingCountnumber1当前页两侧各显示的页数。
childrenReactNode—自定义项目标记;省略时渲染自动生成的页面列表。
getPageHref(page: number) => string—构建每页的href,让服务端外壳渲染无须JavaScript即可工作的真实链接。
renderReactElement | ((props, state) => ReactElement)—替换渲染元素,同时保留行为和无障碍连接关系。

Pagination.List

属性类型默认值说明
childrenReactNode—在列表内渲染的分页项。
renderReactElement | ((props, state) => ReactElement)—替换渲染元素,同时保留行为和无障碍连接关系。

Pagination.Item

属性类型默认值说明
childrenReactNode—单个分页列表项的内容。
renderReactElement | ((props, state) => ReactElement)—替换渲染元素,同时保留行为和无障碍连接关系。

Pagination.Link

Pagination.Ellipsis

属性类型默认值说明
childrenReactNode—省略号内容,对辅助技术隐藏。
renderReactElement | ((props, state) => ReactElement)—替换渲染元素,同时保留行为和无障碍连接关系。

键盘

按键操作
Tab将焦点移入或移出控件
Enter / Space获得焦点时激活(按钮类控件)

无障碍

尽可能使用语义化HTML。可在交互示例中检查渲染的标记;仅在原生元素无法满足需求时添加ARIA。

样式钩子

data-disabled
本页由机器翻译,尚未经人工审核。