Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Display tables with sticky headers that remain visible while scroll

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 **normal Markdown table**. As you scroll down the page, the entire table, including the header, scrolls out of view.

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

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

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

### Style a sticky table
### Using HTML

Simply add the `sticky` attribute to the opening `<table>` tag. No further changes to your table syntax are needed.

<Tabs>
<Tab title="Markdown">
<CodeBlock>
```markdown
<table sticky className="fern-table">
<thead>
<tr>
<th>Plant</th>
<th>Light Requirements</th>
<th>Water</th>
</tr>
</thead>
<tbody>
<tr>
<td>Fern</td>
<td>Partial shade</td>
<td>Weekly</td>
</tr>
<tr>
<td>Snake Plant</td>
<td>Low to bright indirect</td>
<td>Bi-weekly</td>
</tr>
</tbody>
</table>
```
</CodeBlock>
</Tab>
<Tab title="Preview">
<table sticky className="fern-table">
<thead>
<tr>
<th>Plant</th>
<th>Light Requirements</th>
<th>Water</th>
</tr>
</thead>
<tbody>
<tr>
<td>Fern</td>
<td>Partial shade</td>
<td>Weekly</td>
</tr>
<tr>
<td>Snake Plant</td>
<td>Low to bright indirect</td>
<td>Bi-weekly</td>
</tr>
</tbody>
</table>
</Tab>
</Tabs>

## Style a sticky table

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

```css
.fern-table.sticky {
//custom css here
}
```
```