You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(pagination): put current page on link element for a11y (#41154)
* docs(pagination): put current page on link element for a11y
* Reorganize and rewrite
* Update pagination.mdx
---------
Co-authored-by: Mark Otto <markdotto@gmail.com>
Copy file name to clipboardExpand all lines: site/src/content/docs/components/pagination.mdx
+32-20Lines changed: 32 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -42,38 +42,42 @@ Looking to use an icon or symbol in place of text for some pagination links? Be
42
42
</ul>
43
43
</nav>`} />
44
44
45
-
## Disabled and active states
45
+
## Active
46
46
47
-
Pagination links are customizable for different circumstances. Use `.disabled` for links that appear un-clickable and `.active` to indicate the current page.
48
-
49
-
While the `.disabled` class uses `pointer-events: none` to _try_ to disable the link functionality of `<a>`s, that CSS property is not yet standardized and doesn’t account for keyboard navigation. As such, you should always add `tabindex="-1"` on disabled links and use custom JavaScript to fully disable their functionality.
47
+
Add `.active` to indicate a `.page-item` is the one currently being viewed. If using an `<a>` on the current page, `aria-current="page"` should be added for assistive technologies.
You can optionally swap out active or disabled anchors for `<span>`, or omit the anchor in the case of the prev/next arrows, to remove click functionality and prevent keyboard focus while retaining intended styles.
61
+
If using a non-interactive element, like a `<span>` for the current page, you may omit the `aria-current` attribute.
62
+
63
+
```html
64
+
<liclass="page-item active">
65
+
<spanclass="page-link">2</span>
66
+
</li>
67
+
```
68
+
69
+
## Disabled
70
+
71
+
Add `.disabled` to a `.page-item` to make it appear un-clickable. While `.disabled` uses `pointer-events: none` to disable the link‘s interactivity, that CSS property is not yet standardized and doesn’t account for keyboard navigation. As such, you should always add `tabindex="-1"` on disabled links and use custom JavaScript to fully disable their functionality.
@@ -82,14 +86,22 @@ You can optionally swap out active or disabled anchors for `<span>`, or omit the
82
86
</ul>
83
87
</nav>`} />
84
88
89
+
And just like active page items, you can swap out the disabled `<a>` for a `<span>` to remove click functionality and prevent keyboard focus while retaining intended styles.
90
+
91
+
```html
92
+
<liclass="page-item disabled">
93
+
<spanclass="page-link">Previous</span>
94
+
</li>
95
+
```
96
+
85
97
## Sizing
86
98
87
99
Fancy larger or smaller pagination? Add `.pagination-lg` or `.pagination-sm` for additional sizes.
0 commit comments