Skip to content

Commit 2a55b45

Browse files
authored
Update sticky-tables.mdx (#619)
1 parent 16e258c commit 2a55b45

File tree

1 file changed

+62
-3
lines changed

1 file changed

+62
-3
lines changed

fern/products/docs/pages/component-library/default-components/sticky-tables.mdx

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Display tables with sticky headers that remain visible while scroll
55

66
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.
77

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.
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.
99

1010
| Plant | Light Requirements | Water |
1111
|-------|-------------------|-------|
@@ -50,6 +50,8 @@ Below is an example of a **sticky table**. As you scroll down the page, the head
5050

5151
## Create a sticky table
5252

53+
### Using Markdown
54+
5355
Simply wrap any Markdown table with `<StickyTable>` tags to make the header sticky. No changes to your table syntax are needed.
5456

5557
<Tabs>
@@ -75,12 +77,69 @@ Simply wrap any Markdown table with `<StickyTable>` tags to make the header stic
7577
</Tab>
7678
</Tabs>
7779

78-
### Style a sticky table
80+
### Using HTML
81+
82+
Simply add the `sticky` attribute to the opening `<table>` tag. No further changes to your table syntax are needed.
83+
84+
<Tabs>
85+
<Tab title="Markdown">
86+
<CodeBlock>
87+
```markdown
88+
<table sticky className="fern-table">
89+
<thead>
90+
<tr>
91+
<th>Plant</th>
92+
<th>Light Requirements</th>
93+
<th>Water</th>
94+
</tr>
95+
</thead>
96+
<tbody>
97+
<tr>
98+
<td>Fern</td>
99+
<td>Partial shade</td>
100+
<td>Weekly</td>
101+
</tr>
102+
<tr>
103+
<td>Snake Plant</td>
104+
<td>Low to bright indirect</td>
105+
<td>Bi-weekly</td>
106+
</tr>
107+
</tbody>
108+
</table>
109+
```
110+
</CodeBlock>
111+
</Tab>
112+
<Tab title="Preview">
113+
<table sticky className="fern-table">
114+
<thead>
115+
<tr>
116+
<th>Plant</th>
117+
<th>Light Requirements</th>
118+
<th>Water</th>
119+
</tr>
120+
</thead>
121+
<tbody>
122+
<tr>
123+
<td>Fern</td>
124+
<td>Partial shade</td>
125+
<td>Weekly</td>
126+
</tr>
127+
<tr>
128+
<td>Snake Plant</td>
129+
<td>Low to bright indirect</td>
130+
<td>Bi-weekly</td>
131+
</tr>
132+
</tbody>
133+
</table>
134+
</Tab>
135+
</Tabs>
136+
137+
## Style a sticky table
79138

80139
Sticky tables can be styled independently from regular tables. To add custom styling, target the `.fern-table.sticky` selector:
81140

82141
```css
83142
.fern-table.sticky {
84143
//custom css here
85144
}
86-
```
145+
```

0 commit comments

Comments
 (0)