Skip to content

Commit 47896df

Browse files
docs(pagination): put current page on link element for a11y
1 parent 7bbbc49 commit 47896df

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

site/src/content/docs/components/pagination.mdx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Looking to use an icon or symbol in place of text for some pagination links? Be
4646

4747
Pagination links are customizable for different circumstances. Use `.disabled` for links that appear un-clickable and `.active` to indicate the current page.
4848

49+
`aria-current="page"` should be put on the link element for the assistive technology to recognize the active element.
50+
4951
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.
5052

5153
<Example code={`<nav aria-label="...">
@@ -54,8 +56,8 @@ While the `.disabled` class uses `pointer-events: none` to _try_ to disable the
5456
<a class="page-link">Previous</a>
5557
</li>
5658
<li class="page-item"><a class="page-link" href="#">1</a></li>
57-
<li class="page-item active" aria-current="page">
58-
<a class="page-link" href="#">2</a>
59+
<li class="page-item active">
60+
<a class="page-link" href="#" aria-current="page">2</a>
5961
</li>
6062
<li class="page-item"><a class="page-link" href="#">3</a></li>
6163
<li class="page-item">
@@ -64,16 +66,16 @@ While the `.disabled` class uses `pointer-events: none` to _try_ to disable the
6466
</ul>
6567
</nav>`} />
6668

67-
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.
69+
You can optionally swap out 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.
6870

6971
<Example code={`<nav aria-label="...">
7072
<ul class="pagination">
7173
<li class="page-item disabled">
7274
<span class="page-link">Previous</span>
7375
</li>
7476
<li class="page-item"><a class="page-link" href="#">1</a></li>
75-
<li class="page-item active" aria-current="page">
76-
<span class="page-link">2</span>
77+
<li class="page-item active">
78+
<a class="page-link" aria-current="page">2</a>
7779
</li>
7880
<li class="page-item"><a class="page-link" href="#">3</a></li>
7981
<li class="page-item">
@@ -98,8 +100,8 @@ Fancy larger or smaller pagination? Add `.pagination-lg` or `.pagination-sm` for
98100

99101
<Example code={`<nav aria-label="...">
100102
<ul class="pagination pagination-sm">
101-
<li class="page-item active" aria-current="page">
102-
<span class="page-link">1</span>
103+
<li class="page-item active">
104+
<a class="page-link" aria-current="page">1</a>
103105
</li>
104106
<li class="page-item"><a class="page-link" href="#">2</a></li>
105107
<li class="page-item"><a class="page-link" href="#">3</a></li>

0 commit comments

Comments
 (0)