Table
import { Table } from "@cherry-design-system/react";
export function Releases() {
return (
<Table scrollLabel="Releases">
<thead>
<tr>
<th>Component</th>
<th data-numeric>Downloads</th>
</tr>
</thead>
<tbody>
<tr>
<td>Button</td>
<td data-numeric>12,840</td>
</tr>
<tr>
<td>Modal</td>
<td data-numeric>9,310</td>
</tr>
</tbody>
</Table>
);
}Table wraps a native <table> in a rounded frame that scrolls sideways when the columns do not fit. Write plain thead, tbody, tr, th and td inside. Cells stay on one line, so narrow screens scroll instead of squeezing columns.
Examples
Numeric and wrapping columns
Put data-numeric on the th and every td of a number column to right-align it in tabular figures. Put data-wrap on a prose cell to let it wrap.
import { Table } from "@cherry-design-system/react";
export function Invoices() {
return (
<Table scrollLabel="Invoices">
<thead>
<tr>
<th scope="col">Invoice</th>
<th scope="col">Note</th>
<th scope="col" data-numeric>Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>INV-0042</td>
<td data-wrap>Annual plan, billed upfront with the volume discount applied.</td>
<td data-numeric>$1,920.00</td>
</tr>
</tbody>
</Table>
);
}Density, stripes and hover
import { Table } from "@cherry-design-system/react";
export function Compact() {
return (
<Table size="sm" striped hoverable={false}>
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr><td>Region</td><td>eu-west-1</td></tr>
<tr><td>Runtime</td><td>Node 22</td></tr>
<tr><td>Memory</td><td>1024 MB</td></tr>
</tbody>
</Table>
);
}Styling the frame
className and style go on the <table>. Use frameClassName and frameStyle for the outer frame.
import { Table } from "@cherry-design-system/react";
export function Tall({ children }: { children: React.ReactNode }) {
return (
<Table frameStyle={{ maxHeight: 400 }} frameClassName="audit-log" scrollLabel="Audit log">
{children}
</Table>
);
}Properties
Row density. Defaults to "md".
Zebra rows.
Highlights rows on hover. Defaults to true.
Names the scroll region and makes it keyboard scrollable, for a table that can overflow.
Class for the outer frame (className goes on the <table>).
Inline style for the outer frame.
Table renders a <div> frame around a <table>. The ref goes to the <table>, and every other <table> attribute passes through to it. It has no client JavaScript, so it is safe in Server Components.
Styling
| Hook | Values |
|---|---|
.cherry-table | The frame |
data-size | sm, md |
data-striped, data-hoverable | On the frame when enabled |
data-numeric, data-wrap | On cells you mark |
.cherry-table__table | The <table> |
The frame reads --cherry-bg-elevated, --cherry-border-default and --cherry-radius-lg; header cells use the label-xs text tokens and --cherry-bg-subtle; hovered rows read --cherry-ghost-hover.
Accessibility
- It is a native table: use
<th>headers, withscopewhere needed. scrollLabelturns a table that can scroll sideways into a named, keyboard-focusable region. Set it whenever the table can overflow.- Add
data-numericto number columns so figures line up.