Skip to content

Commit 47ef0a8

Browse files
ngyikpXhmikosR
authored andcommitted
Improve pagination's documentation accessibility.
- Remove `.sr-only` span for previous/next page, there is already`aria-label` - Add `aria-disabled="true"` and `aria-current="page"`
1 parent 557f3fe commit 47ef0a8

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

site/docs/4.1/components/pagination.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ In addition, as pages likely have more than one such navigation section, it's ad
2727

2828
## Working with icons
2929

30-
Looking to use an icon or symbol in place of text for some pagination links? Be sure to provide proper screen reader support with `aria` attributes and the `.sr-only` utility.
30+
Looking to use an icon or symbol in place of text for some pagination links? Be sure to provide proper screen reader support with `aria` attributes.
3131

3232
{% capture example %}
3333
<nav aria-label="Page navigation example">
3434
<ul class="pagination">
3535
<li class="page-item">
3636
<a class="page-link" href="#" aria-label="Previous">
3737
<span aria-hidden="true">&laquo;</span>
38-
<span class="sr-only">Previous</span>
3938
</a>
4039
</li>
4140
<li class="page-item"><a class="page-link" href="#">1</a></li>
@@ -44,7 +43,6 @@ Looking to use an icon or symbol in place of text for some pagination links? Be
4443
<li class="page-item">
4544
<a class="page-link" href="#" aria-label="Next">
4645
<span aria-hidden="true">&raquo;</span>
47-
<span class="sr-only">Next</span>
4846
</a>
4947
</li>
5048
</ul>
@@ -62,10 +60,10 @@ While the `.disabled` class uses `pointer-events: none` to _try_ to disable the
6260
<nav aria-label="...">
6361
<ul class="pagination">
6462
<li class="page-item disabled">
65-
<a class="page-link" href="#" tabindex="-1">Previous</a>
63+
<a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
6664
</li>
6765
<li class="page-item"><a class="page-link" href="#">1</a></li>
68-
<li class="page-item active">
66+
<li class="page-item active" aria-current="page">
6967
<a class="page-link" href="#">2 <span class="sr-only">(current)</span></a>
7068
</li>
7169
<li class="page-item"><a class="page-link" href="#">3</a></li>
@@ -86,7 +84,7 @@ You can optionally swap out active or disabled anchors for `<span>`, or omit the
8684
<span class="page-link">Previous</span>
8785
</li>
8886
<li class="page-item"><a class="page-link" href="#">1</a></li>
89-
<li class="page-item active">
87+
<li class="page-item active" aria-current="page">
9088
<span class="page-link">
9189
2
9290
<span class="sr-only">(current)</span>
@@ -108,8 +106,11 @@ Fancy larger or smaller pagination? Add `.pagination-lg` or `.pagination-sm` for
108106
{% capture example %}
109107
<nav aria-label="...">
110108
<ul class="pagination pagination-lg">
111-
<li class="page-item disabled">
112-
<a class="page-link" href="#" tabindex="-1">1</a>
109+
<li class="page-item active" aria-current="page">
110+
<span class="page-link">
111+
1
112+
<span class="sr-only">(current)</span>
113+
</span>
113114
</li>
114115
<li class="page-item"><a class="page-link" href="#">2</a></li>
115116
<li class="page-item"><a class="page-link" href="#">3</a></li>
@@ -121,8 +122,11 @@ Fancy larger or smaller pagination? Add `.pagination-lg` or `.pagination-sm` for
121122
{% capture example %}
122123
<nav aria-label="...">
123124
<ul class="pagination pagination-sm">
124-
<li class="page-item disabled">
125-
<a class="page-link" href="#" tabindex="-1">1</a>
125+
<li class="page-item active" aria-current="page">
126+
<span class="page-link">
127+
1
128+
<span class="sr-only">(current)</span>
129+
</span>
126130
</li>
127131
<li class="page-item"><a class="page-link" href="#">2</a></li>
128132
<li class="page-item"><a class="page-link" href="#">3</a></li>
@@ -139,7 +143,7 @@ Change the alignment of pagination components with [flexbox utilities]({{ site.b
139143
<nav aria-label="Page navigation example">
140144
<ul class="pagination justify-content-center">
141145
<li class="page-item disabled">
142-
<a class="page-link" href="#" tabindex="-1">Previous</a>
146+
<a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
143147
</li>
144148
<li class="page-item"><a class="page-link" href="#">1</a></li>
145149
<li class="page-item"><a class="page-link" href="#">2</a></li>
@@ -156,7 +160,7 @@ Change the alignment of pagination components with [flexbox utilities]({{ site.b
156160
<nav aria-label="Page navigation example">
157161
<ul class="pagination justify-content-end">
158162
<li class="page-item disabled">
159-
<a class="page-link" href="#" tabindex="-1">Previous</a>
163+
<a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
160164
</li>
161165
<li class="page-item"><a class="page-link" href="#">1</a></li>
162166
<li class="page-item"><a class="page-link" href="#">2</a></li>

0 commit comments

Comments
 (0)