Skip to content

Data display

Table

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

tsx
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

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

tsx
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

size"sm" | "md"

Row density. Defaults to "md".

stripedboolean

Zebra rows.

hoverableboolean

Highlights rows on hover. Defaults to true.

scrollLabelstring

Names the scroll region and makes it keyboard scrollable, for a table that can overflow.

frameClassNamestring

Class for the outer frame (className goes on the <table>).

frameStyleCSSProperties

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

HookValues
.cherry-tableThe frame
data-sizesm, md
data-striped, data-hoverableOn the frame when enabled
data-numeric, data-wrapOn cells you mark
.cherry-table__tableThe <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, with scope where needed.
  • scrollLabel turns a table that can scroll sideways into a named, keyboard-focusable region. Set it whenever the table can overflow.
  • Add data-numeric to number columns so figures line up.