Skip to content

Commit 491e5d2

Browse files
authored
Add new page on StickyTables (Docs) (#555)
1 parent b5d7d05 commit 491e5d2

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

fern/products/docs/docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ navigation:
8484
- page: Steps
8585
path: ./pages/component-library/default-components/steps.mdx
8686
icon: fa-duotone fa-list-ol
87+
- page: Sticky tables
88+
path: ./pages/component-library/default-components/sticky-tables.mdx
89+
icon: fa-duotone fa-table
8790
- page: Tabs
8891
path: ./pages/component-library/default-components/tabs.mdx
8992
icon: fa-duotone fa-folder-open
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
title: Sticky tables
3+
description: Display tables with sticky headers that remain visible while scrolling through table data.
4+
---
5+
6+
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.
7+
8+
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.
9+
10+
| Plant | Light Requirements | Water |
11+
|-------|-------------------|-------|
12+
| Fern | Partial shade | Weekly |
13+
| Snake Plant | Low to bright indirect | Bi-weekly |
14+
| Monstera | Bright indirect | Weekly |
15+
| Pothos | Low to bright indirect | Weekly |
16+
| Fiddle Leaf Fig | Bright indirect | Weekly |
17+
| Peace Lily | Low to medium indirect | Weekly |
18+
| Rubber Plant | Bright indirect | Weekly |
19+
| ZZ Plant | Low to bright indirect | Bi-weekly |
20+
| Philodendron | Medium to bright indirect | Weekly |
21+
| Aloe Vera | Bright direct | Bi-weekly |
22+
| Boston Fern | Partial shade | 2-3x weekly |
23+
| Spider Plant | Medium to bright indirect | Weekly |
24+
| Dracaena | Medium indirect | Weekly |
25+
| Bird of Paradise | Bright indirect to direct | Weekly |
26+
| Calathea | Medium indirect | Weekly |
27+
28+
29+
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.
30+
31+
<StickyTable>
32+
| Plant | Light Requirements | Water |
33+
|-------|-------------------|-------|
34+
| Fern | Partial shade | Weekly |
35+
| Snake Plant | Low to bright indirect | Bi-weekly |
36+
| Monstera | Bright indirect | Weekly |
37+
| Pothos | Low to bright indirect | Weekly |
38+
| Fiddle Leaf Fig | Bright indirect | Weekly |
39+
| Peace Lily | Low to medium indirect | Weekly |
40+
| Rubber Plant | Bright indirect | Weekly |
41+
| ZZ Plant | Low to bright indirect | Bi-weekly |
42+
| Philodendron | Medium to bright indirect | Weekly |
43+
| Aloe Vera | Bright direct | Bi-weekly |
44+
| Boston Fern | Partial shade | 2-3x weekly |
45+
| Spider Plant | Medium to bright indirect | Weekly |
46+
| Dracaena | Medium indirect | Weekly |
47+
| Bird of Paradise | Bright indirect to direct | Weekly |
48+
| Calathea | Medium indirect | Weekly |
49+
</StickyTable>
50+
51+
## Create a sticky table
52+
53+
Simply wrap any Markdown table with `<StickyTable>` tags to make the header sticky. No changes to your table syntax are needed.
54+
55+
<Tabs>
56+
<Tab title="Markdown">
57+
<CodeBlock>
58+
```markdown
59+
<StickyTable>
60+
61+
| Plant | Light Requirements | Water |
62+
|-------|-------------------|-------|
63+
| Fern | Partial shade | Weekly |
64+
| Snake Plant | Low to bright indirect | Bi-weekly |
65+
66+
</StickyTable>
67+
```
68+
</CodeBlock>
69+
</Tab>
70+
<Tab title="Preview">
71+
| Plant | Light Requirements | Water |
72+
|-------|-------------------|-------|
73+
| Fern | Partial shade | Weekly |
74+
| Snake Plant | Low to bright indirect | Bi-weekly |
75+
</Tab>
76+
</Tabs>
77+
78+
### Style a sticky table
79+
80+
Sticky tables can be styled independently from regular tables. To add custom styling, target the `.fern-table.sticky` selector:
81+
82+
```css
83+
.fern-table.sticky {
84+
//custom css here
85+
}
86+
```

0 commit comments

Comments
 (0)