]> git.ipfire.org Git - ipfire.org.git/blob - static/scss/bootstrap-4.0.0-alpha.6/docs/components/pagination.md
.gitignore: Add .vscode
[ipfire.org.git] / static / scss / bootstrap-4.0.0-alpha.6 / docs / components / pagination.md
1 ---
2 layout: docs
3 title: Pagination
4 description: Documentation and examples for showing pagination links.
5 group: components
6 ---
7
8 Pagination links indicate a series of related content exists across multiple pages. Typically these are used where a multi-page approach to long lists of content improves general performance, such as in search results or inboxes.
9
10 ## Contents
11
12 * Will be replaced with the ToC, excluding the "Contents" header
13 {:toc}
14
15 ## Overview
16
17 We use a large block of connected links for our pagination, making links hard to miss and easily scalable—all while providing large hit areas. Pagination is built with list HTML elements so screen readers can announce the number of available links. Use a wrapping `<nav>` element to identify it as a navigation section to screen readers and other assistive technologies.
18
19 In addition, as pages likely have more than one such navigation section, it's advisable to provide a descriptive `aria-label` for the `<nav>` to reflect its purpose. For example, if the pagination component is used to navigate between a set of search results, an appropriate label could be `aria-label="Search results pages"`.
20
21 {% example html %}
22 <nav aria-label="Page navigation example">
23 <ul class="pagination">
24 <li class="page-item"><a class="page-link" href="#">Previous</a></li>
25 <li class="page-item"><a class="page-link" href="#">1</a></li>
26 <li class="page-item"><a class="page-link" href="#">2</a></li>
27 <li class="page-item"><a class="page-link" href="#">3</a></li>
28 <li class="page-item"><a class="page-link" href="#">Next</a></li>
29 </ul>
30 </nav>
31 {% endexample %}
32
33 ## Working with icons
34
35 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.
36
37 {% example html %}
38 <nav aria-label="Page navigation example">
39 <ul class="pagination">
40 <li class="page-item">
41 <a class="page-link" href="#" aria-label="Previous">
42 <span aria-hidden="true">&laquo;</span>
43 <span class="sr-only">Previous</span>
44 </a>
45 </li>
46 <li class="page-item"><a class="page-link" href="#">1</a></li>
47 <li class="page-item"><a class="page-link" href="#">2</a></li>
48 <li class="page-item"><a class="page-link" href="#">3</a></li>
49 <li class="page-item">
50 <a class="page-link" href="#" aria-label="Next">
51 <span aria-hidden="true">&raquo;</span>
52 <span class="sr-only">Next</span>
53 </a>
54 </li>
55 </ul>
56 </nav>
57 {% endexample %}
58
59 ## Disabled and active states
60
61 Pagination links are customizable for different circumstances. Use `.disabled` for links that appear un-clickable and `.active` to indicate the current page.
62
63 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.
64
65 {% example html %}
66 <nav aria-label="...">
67 <ul class="pagination">
68 <li class="page-item disabled">
69 <a class="page-link" href="#" tabindex="-1">Previous</a>
70 </li>
71 <li class="page-item"><a class="page-link" href="#">1</a></li>
72 <li class="page-item active">
73 <a class="page-link" href="#">2 <span class="sr-only">(current)</span></a>
74 </li>
75 <li class="page-item"><a class="page-link" href="#">3</a></li>
76 <li class="page-item">
77 <a class="page-link" href="#">Next</a>
78 </li>
79 </ul>
80 </nav>
81 {% endexample %}
82
83 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.
84
85 {% example html %}
86 <nav aria-label="...">
87 <ul class="pagination">
88 <li class="page-item disabled">
89 <span class="page-link">Previous</span>
90 </li>
91 <li class="page-item"><a class="page-link" href="#">1</a></li>
92 <li class="page-item active">
93 <span class="page-link">
94 2
95 <span class="sr-only">(current)</span>
96 </span>
97 </li>
98 <li class="page-item"><a class="page-link" href="#">3</a></li>
99 <li class="page-item">
100 <a class="page-link" href="#">Next</a>
101 </li>
102 </ul>
103 </nav>
104 {% endexample %}
105
106 ## Sizing
107
108 Fancy larger or smaller pagination? Add `.pagination-lg` or `.pagination-sm` for additional sizes.
109
110 {% example html %}
111 <nav aria-label="...">
112 <ul class="pagination pagination-lg">
113 <li class="page-item disabled">
114 <a class="page-link" href="#" tabindex="-1">Previous</a>
115 </li>
116 <li class="page-item"><a class="page-link" href="#">1</a></li>
117 <li class="page-item"><a class="page-link" href="#">2</a></li>
118 <li class="page-item"><a class="page-link" href="#">3</a></li>
119 <li class="page-item">
120 <a class="page-link" href="#">Next</a>
121 </li>
122 </ul>
123 </nav>
124 {% endexample %}
125
126 {% example html %}
127 <nav aria-label="...">
128 <ul class="pagination pagination-sm">
129 <li class="page-item disabled">
130 <a class="page-link" href="#" tabindex="-1">Previous</a>
131 </li>
132 <li class="page-item"><a class="page-link" href="#">1</a></li>
133 <li class="page-item"><a class="page-link" href="#">2</a></li>
134 <li class="page-item"><a class="page-link" href="#">3</a></li>
135 <li class="page-item">
136 <a class="page-link" href="#">Next</a>
137 </li>
138 </ul>
139 </nav>
140 {% endexample %}
141
142 ## Alignment
143
144 Change the alignment of pagination components with [flexbox utilities]({{ site.baseurl }}/utilities/flexbox/).
145
146 {% example html %}
147 <nav aria-label="Page navigation example">
148 <ul class="pagination justify-content-center">
149 <li class="page-item disabled">
150 <a class="page-link" href="#" tabindex="-1">Previous</a>
151 </li>
152 <li class="page-item"><a class="page-link" href="#">1</a></li>
153 <li class="page-item"><a class="page-link" href="#">2</a></li>
154 <li class="page-item"><a class="page-link" href="#">3</a></li>
155 <li class="page-item">
156 <a class="page-link" href="#">Next</a>
157 </li>
158 </ul>
159 </nav>
160 {% endexample %}
161
162 {% example html %}
163 <nav aria-label="Page navigation example">
164 <ul class="pagination justify-content-end">
165 <li class="page-item disabled">
166 <a class="page-link" href="#" tabindex="-1">Previous</a>
167 </li>
168 <li class="page-item"><a class="page-link" href="#">1</a></li>
169 <li class="page-item"><a class="page-link" href="#">2</a></li>
170 <li class="page-item"><a class="page-link" href="#">3</a></li>
171 <li class="page-item">
172 <a class="page-link" href="#">Next</a>
173 </li>
174 </ul>
175 </nav>
176 {% endexample %}