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
Add a `.thead-sticky` class so a `<thead>` stays visible while the `<tbody>`
scrolls. Add `--table-thead-sticky-top` and `--table-thead-sticky-zindex`
tokens to offset fixed headers and control stacking. Document the class and
shorten several table headings.
Copy file name to clipboardExpand all lines: site/src/content/docs/content/tables.mdx
+74-4Lines changed: 74 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -205,7 +205,7 @@ Highlight a table row or cell by adding a `.table-active` class.
205
205
</table>
206
206
`} />
207
207
208
-
## How do the variants and accented tables work?
208
+
## Variants explained
209
209
210
210
For the accented tables ([striped rows](#striped-rows), [striped columns](#striped-columns), [hoverable rows](#hoverable-rows), and [active tables](#active-tables)), we used some techniques to make these effects work for all our [table variants](#variants):
211
211
@@ -225,7 +225,7 @@ Behind the scenes it looks like this:
225
225
226
226
## Table borders
227
227
228
-
### Bordered tables
228
+
### Bordered
229
229
230
230
Add `.table-bordered` for borders on all sides of the table and cells.
231
231
@@ -235,7 +235,7 @@ Add `.table-bordered` for borders on all sides of the table and cells.
Add `.table-borderless` for a table without borders.
241
241
@@ -427,7 +427,7 @@ Border styles, active styles, and table variants are not inherited by nested tab
427
427
</table>
428
428
`} />
429
429
430
-
## How nesting works
430
+
###How nesting works
431
431
432
432
To prevent *any* styles from leaking to nested tables, we use the child combinator (`>`) selector in our CSS. Since we need to target all the `td`s and `th`s in the `thead`, `tbody`, and `tfoot`, our selector would look pretty long without it. As such, we use the rather odd looking `.table > :not(caption) > * > *` selector to target all `td`s and `th`s of the `.table`, but none of any potential nested tables.
433
433
@@ -619,6 +619,76 @@ Both `.table-stacked` and `.table-responsive` use container queries, so the `.ta
619
619
</div>
620
620
```
621
621
622
+
## Sticky table headers
623
+
624
+
Add `.thead-sticky` to a `<thead>` to keep it in view while the `<tbody>` contents scroll. The table needs a scrollable parent, such as a container with a fixed height. Set the `--bs-table-thead-sticky-top` CSS variable to offset any fixed headers or navigation above the table.
Responsive tables allow tables to be scrolled horizontally with ease. Make any table responsive across all viewports by wrapping a `.table` with `.table-responsive`. Or, pick a maximum breakpoint with which to have a responsive table up to by using `.{sm|md|lg|xl|2xl}:table-responsive`.
0 commit comments