Skip to content
Site volume
Colourway

Components

Table sort button

The sort key inside a table head: the column's name and a glyph for its order.

  • Experimental
  • Reading layer
  • Client leaf
  • Since 0.9.0
  • Press check
Import from@maxgrits/overprint-react/table
On this page

TableSortButton turns a column head into a sort key: the column's name in the head's label role and a play glyph that points up for ascending and down for descending (an open diamond while the column is not sorted). It writes aria-sort on its header cell and reports the next order through onSortChange.

Example#

Look of this example
Projects by score
Project
Fernlight98
Pebblepath91
Live render of examples/table-sort-button/basic.tsx

Usage#

Use a sort button in a column head when people need to reorder a table by that column: projects by score, invoices by date. It writes aria-sort on its head cell and reports the next order through onSortChange; the table sorts its own rows.

  • States. Ascending points the glyph up, descending down; an open diamond marks a column that can be sorted but is not.
  • One sorted column at a time; the others return to the diamond.

Anatomy#

Projects by score
Project
Fernlight98
Pebblepath91
The parts of examples/table-sort-button/basic.tsx, numbered:
  1. Labeldata-mk-part="label"
  2. Markdata-mk-part="mark"

Volume#

Reading layer: identical at every volume.

  • Quiet

    Projects by score
    Project
    Fernlight98
    Pebblepath91

    Docs, forms, legal and long reads. Flat inks, no art in motion.

  • Studio

    Projects by score
    Project
    Fernlight98
    Pebblepath91

    The site default. Art on its own plates, one display moment per view.

  • Press

    Projects by score
    Project
    Fernlight98
    Pebblepath91

    Hero moments, covers and campaigns. Halftone fields and the second ink.

  • Rave

    Projects by score
    Project
    Fernlight98
    Pebblepath91

    Launches, posters and the 404. Every ink, and the words still win.

Content#

  • The label is the column's name; the order is in the glyph and aria-sort, never in extra words.

Do and don't#

Do

Projects by score
Project
Fernlight98
Pebblepath91

Sort where order means something.

Don't

Every column sortable, including the notes column nobody sorts.

Sort keys on every head.

A sort key is a promise that order matters. Put it on the columns people actually rank by.

Accessibility#

  • The header cell, not the button, carries aria-sort, so screen readers announce the order with the column.
  • The order never rests on colour: the glyph's direction and shape say it.
  • A plain button: Tab reaches it, Enter and Space sort.
KeysWhat happens
TabMoves to the sort key in a column head
EnterorSpaceSorts the column (ascending, then descending)

The colour pairs it prints, with their contrast on both papers:

TextSurfaceRoleBoneNight
--mk-text--mk-surfaceuinot in this looknot in this look

Process at Studio, normal contrast. Every look: the press check.

Props#

PropTypeDefaultDescription
sort requiredTableSortnone
onSortChange((next: Exclude<TableSort, "none">) => void)none
children requiredReactNodenoneThe column's name.

Plus 289 React and DOM attributes passed through to the root element (className, ref, aria-*, event handlers and the rest). Generated from TableSortButtonProps in packages/overprint-react/src/reading/table/table-sort-button.tsx.

Tokens#

System tokens (3)

Scanned from its CSS at build and checked against its registry entry.

Changelog#

Arrived in 0.9.0.

0.9.024 October 2026