Skip to content

Add sticky table headers - #42837

Open
mdo wants to merge 2 commits into
v6-devfrom
table-sticky-headers
Open

mdo wants to merge 2 commits into
v6-devfrom
table-sticky-headers

Conversation

@mdo

@mdo mdo commented Aug 13, 2026

Copy link
Copy Markdown
Member
  • Add a .thead-sticky class that keeps a <thead> in view while the <tbody> scrolls inside a scrollable parent.
  • Add --table-thead-sticky-top and --table-thead-sticky-zindex tokens to offset fixed headers and control stacking.
  • Document the new class with a scrollable example.
  • Shorten several table headings and demote "How nesting works" to an h3.

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.
@mdo
mdo requested a review from a team as a code owner August 13, 2026 02:25
@mdo mdo added this to v6.0.0 Aug 13, 2026
@github-project-automation github-project-automation Bot moved this to Inbox in v6.0.0 Aug 13, 2026
Scroll a table with `.thead-sticky`: a 1px strip of the next row
shows above the header.

`border-collapse` shares that border, so `top: 0` cannot cover it.
Offset sticky `top` by the table border width and clip the example
in an `overflow-hidden` wrapper.
@coliff

coliff commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

PREVIEW:
https://deploy-preview-42837--twbs-bootstrap.netlify.app/docs/6.0/content/tables/#sticky-table-headers

Happy to see this being added. This was one of my only remaining feature requests for v6 :-)

In the example looks like the header jumps one pixel when scrolling down. Also, I would like thead-sticky to either have a bottom border by default or at least support adding the border-bottom class.

@mdo

mdo commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

In the example looks like the header jumps one pixel when scrolling down. Also, I would like thead-sticky to either have a bottom border by default or at least support adding the border-bottom class.

Yeah, needs some refinement. I think something with the border behavior on tables is interfering with the top offset—maybe the border-collapse.

@coliff

coliff commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

I think something with the border behavior on tables is interfering with the top offset—maybe the border-collapse.

Yes, I researched this a good few years ago. I found it tricky to get right and think I resorted to use a 1px inset-shadow (but of a hacky workaround but it worked/looked correct visually). Alternatively the user could specify a different color background for the sticky header to differentiate it and help negate the need for a bottom-border. I might look into it again today and report back...

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

2 participants