Sticky tables
The StickyTable
component provides a way to display tabular data with a fixed header that remains visible while scrolling through table rows. This is particularly useful for longer tables where users need to reference column headers while viewing data further down the table.
Below is an example of a normal Markdown table. As you scroll down the page, the entire table, including the header, scrolls out of view.
Below is an example of a sticky table. As you scroll down the page, the header row remains frozen at the top of the table.
Plant | Light Requirements | Water |
---|---|---|
Fern | Partial shade | Weekly |
Snake Plant | Low to bright indirect | Bi-weekly |
Monstera | Bright indirect | Weekly |
Pothos | Low to bright indirect | Weekly |
Fiddle Leaf Fig | Bright indirect | Weekly |
Peace Lily | Low to medium indirect | Weekly |
Rubber Plant | Bright indirect | Weekly |
ZZ Plant | Low to bright indirect | Bi-weekly |
Philodendron | Medium to bright indirect | Weekly |
Aloe Vera | Bright direct | Bi-weekly |
Boston Fern | Partial shade | 2-3x weekly |
Spider Plant | Medium to bright indirect | Weekly |
Dracaena | Medium indirect | Weekly |
Bird of Paradise | Bright indirect to direct | Weekly |
Calathea | Medium indirect | Weekly |
Create a sticky table
Using Markdown
Simply wrap any Markdown table with <StickyTable>
tags to make the header sticky. No changes to your table syntax are needed.
Markdown
Preview
Using HTML
Simply add the sticky
attribute to the opening <table>
tag. No further changes to your table syntax are needed.
Markdown
Preview
Style a sticky table
Sticky tables can be styled independently from regular tables. To add custom styling, target the .fern-table.sticky
selector: