Kinetik UI

Sort Table

.md

A table sorted by tapping a column: rows spring from their old places to their new ones as the arrow turns.

v1.0.0Live on webreact-native-reanimatedreact-native-worklets
Component preview

Installation

Kinetik CLI
npx kinetik-ui add sort-table

The CLI copies the source and installs native dependencies with npx expo install, so versions match your Expo SDK. With shadcn: npx shadcn@latest add https://kinetik-ui.dev/r/sort-table.json

Install manually

  1. Install dependencies
    npx expo install react-native-reanimated react-native-worklets
  2. Copy the source files
    • components/kinetik/sort-table.tsx
    View source files

Usage

import { SortTable } from '@/components/kinetik/sort-table';

<SortTable
  columns={[
    { key: 'city', title: 'City', flex: 1.6 },
    { key: 'orders', title: 'Orders', align: 'right' },
    { key: 'growth', title: 'Growth', align: 'right', format: (v) => `${v}%` },
  ]}
  rows={[
    { id: 'lis', city: 'Lisbon', orders: 1840, growth: 12 },
    { id: 'ber', city: 'Berlin', orders: 3120, growth: 4 },
  ]}
  initialSort={{ key: 'orders', dir: 'desc' }}
/>;

When to use

  • A short table of records people compare by different measures: cities, plans, players, products.
  • Places where watching rows move tells people what changed when they re-sort.

When not to use

  • Long lists (more than about 50 rows). Every row is laid out at once; use a virtualised list with a sort menu.
  • Wide tables with many columns on a phone. Show fewer columns or a card per record.

Notes

  • A new column sorts numbers high to low and text A to Z; tapping it again flips the direction. Ties keep their original order.
  • Rows keep their identity (id) and spring from their old place to their new one.
  • Headers read their sort state ("Orders, sorted descending") and every row reads each column's title and value.
  • With reduced motion rows jump to their new places.

Props

SortTableProps

PropTypeDefaultDescription
columnsrequiredreadonly SortColumn[]—
rowsrequiredreadonly SortRow[]—
initialSortSortState—
onSortChange(sort: SortState) => void—
hapticsbooleantrueA tick when the order changes. Defaults to true.
testIDstring—
styleStyleProp<ViewStyle>—

Performance and accessibility

Performance

Budget
Plain views; each row moves by one transform on one shared value, so a sort never lays the table out again. Nothing runs at rest.
Measured

Pixel 9 emulator, API 35, release build · interaction median 0.94× the system Settings app on the same emulator (indicative only) · no frames drawn at rest · 142 MB app memory

Real-device measurement pending.

Accessibility

Reduced motion
Rows jump to their new places and the arrow turns at once.
Screen readers
Headers are buttons that read their sort state; each row reads every column's title and value.
Touch target
Headers are 44 pt tall and as wide as their column.

Source files

components/kinetik/sort-table.tsx is in the Code tab of the preview above.