Northwind Studio$2,915.50Paid21 Nov
Meridian Labs$1,240.00Paid12 Nov
Jonas Weller$742.80Pending26 Nov
Mira Okafor$380.00Pending18 Nov
Tessel & Co$96.00Overdue2 Nov

Code

<!-- pearl-table.free.js: download it from the Install section below and host it with your site -->
<script src="/pearl-table.free.js" defer></script>

<pearl-table sort="1" dir="desc" selectable="multiple" size="48" theme="light">
  <table>
    <thead>
      <tr>
        <th>Customer</th>
        <th data-sort="number">Amount</th>
        <th>Status</th>
        <th data-sort="none" data-align="end">Due</th>
      </tr>
    </thead>
    <tbody>
      <tr><td>Meridian Labs</td><td>$1,240.00</td><td>Paid</td><td>12 Nov</td></tr>
      <tr><td>Mira Okafor</td><td>$380.00</td><td>Pending</td><td>18 Nov</td></tr>
      <tr><td>Northwind Studio</td><td>$2,915.50</td><td>Paid</td><td>21 Nov</td></tr>
    </tbody>
  </table>
</pearl-table>

<script>
  const table = document.querySelector('pearl-table');
  table.addEventListener('sort', (e) => console.log(e.detail.column, e.detail.dir));
  table.addEventListener('select', (e) => console.log(e.detail.rows));
</script>

In context

Mira Okafor27
Ada Lindqvist14
Theo Marchetti9
Jonas Weller3
Two columns, one row selected
Starter$0
Team$48
Business$160
Enterprise$640
Sunset Pro

Install · Free Web Component

One file, no dependencies. Aurora preset, every other option included. Host it yourself so your visitors never load anything from our servers.

1. Install with one command — or download the file
shadcn CLI · React
npx shadcn@latest add https://www.ui-design.co/r/pearl-table.json
2. Load it and use the element
HTML
<!-- pearl-table.free.js: download it from the Install section below and host it with your site -->
<script src="/pearl-table.free.js" defer></script>

<pearl-table sort="1" dir="desc" selectable="multiple" size="48" theme="light">
  <table>
    <thead>
      <tr>
        <th>Customer</th>
        <th data-sort="number">Amount</th>
        <th>Status</th>
        <th data-sort="none" data-align="end">Due</th>
      </tr>
    </thead>
    <tbody>
      <tr><td>Meridian Labs</td><td>$1,240.00</td><td>Paid</td><td>12 Nov</td></tr>
      <tr><td>Mira Okafor</td><td>$380.00</td><td>Pending</td><td>18 Nov</td></tr>
      <tr><td>Northwind Studio</td><td>$2,915.50</td><td>Paid</td><td>21 Nov</td></tr>
    </tbody>
  </table>
</pearl-table>

<script>
  const table = document.querySelector('pearl-table');
  table.addEventListener('sort', (e) => console.log(e.detail.column, e.detail.dir));
  table.addEventListener('select', (e) => console.log(e.detail.rows));
</script>
3. React + TypeScript (optional)

The shadcn command adds a typed React wrapper for you. Using the file directly? Custom elements work in React as-is; for type checking add:

TypeScript
// pearl-table.d.ts
declare namespace JSX {
  interface IntrinsicElements {
    'pearl-table': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
      sort?: number | string;
      dir?: 'asc' | 'desc';
      selectable?: 'none' | 'single' | 'multiple';
      sticky?: boolean | '';
      height?: number | string;
      size?: number | string;
      width?: number | string;
      radius?: number | string;
      theme?: 'light' | 'dark';
      sound?: boolean | '';
    };
  }
}

Pro · React + TypeScript Pro

One payment of $4.99, yours forever. Use it in unlimited personal and commercial projects; no resale.

  • React component driven by columns and rows — cells take any React content — with TypeScript types and the full source
  • Sunset, Mint and Mono tints, plus custom tints from Brand Fit
  • The vanilla Web Component with every tint, a demo page, README and license

Attributes & props

NameTypeDefaultDescription
<table> child—A plain HTML table with a thead and a tbody. It stays a real table: without the script it is still readable. Call el.refresh() after adding rows from script.
<th data-sort> 'text' | 'number' | 'none''text'How a column sorts. number reads "$1,240.00" or "12%" as a number; none leaves the header as plain text. A cell can carry data-value="…" to sort by something other than its text.
<th data-align> 'start' | 'end'end for numbersend right-aligns the column and uses tabular numerals.
sort column index | data-key | label—The sorted column. Changes when a header is pressed and fires sort with detail.column, detail.key and detail.dir.
dir 'asc' | 'desc''asc'Sort direction.
selectable 'none' | 'single' | 'multiple''none'Rows can be selected by click, Space or Enter. Fires select with detail.rows — indices in the original order. Mark a row <tr selected> to start with it selected; el.selected reads and sets the list.
sticky booleanoffThe header stays in place while the body scrolls inside height.
height number (px)320Max height of the scrolling area, with sticky.
size number (px)48Row height; the type and the paddings scale with it.
width number (px) | CSS width100%Slab width. When the columns do not fit, the table scrolls sideways inside the slab.
theme 'light' | 'dark''light'White porcelain or dark.
sound booleanoffA porcelain tap on sort and select. Also on for everything inside an element with data-ui-sound="on".
tint Pro'aurora' | 'sunset' | 'mint' | 'mono' | object'aurora'Colours of the sort bead and the selection strand, or a custom tint. Free build ships Aurora only.

It is a real <table>: column headers have scope="col" and aria-sort, and each sortable header is a button. With selectable the table becomes a grid: Tab reaches one row, Up / Down, Home and End move between rows, Space or Enter selects, and rows carry aria-selected. Every click on a row also fires rowclick with detail.index (links and buttons inside a cell keep working and do not select). The sort animation moves rows with transforms only, so there is no layout thrash; reduced motion sorts at once. Sorting happens in the browser — for server-side sorting, listen to sort and replace the rows. All CSS, no WebGL.

More components