Oddmash UI
所有组件

Pagination

在结果页之间切换。

用法

有独立 URL 时使用链接,当前页设置 aria-current="page"。

无障碍

为链接命名,并禁用无法执行的翻页操作。

属性类型默认值
aria-labelstringPagination
const Example = () => {
  const [currentPage, setCurrentPage] = useState(2);
  return (
    <Pagination aria-label="Example pagination">
      {[1, 2, 3].map((page) => (
        <button
          key={page}
          type="button"
          aria-label={`Page ${page}`}
          aria-current={page === currentPage ? 'page' : undefined}
          onClick={() => setCurrentPage(page)}
        >
          {page}
        </button>
      ))}
    </Pagination>
  );
};

交互式文档