Skip to content
silverpoint
Documentation menu

UI components · Composed · new in 0.7

SpTable

Card-framed table: small-caps header, tabular figures, hatched striping, sortable headers with aria-sort. Group: Composed · new in silverpoint 0.7, in React, Vue, Angular and Reflex (sp_table · sort_rows).

Live

Drawn here with the Reflex version, sp_table · sort_rows, on the ground you pick:

Ground
Substrate
Mode
Palette
On-call teams
Region
CatalogSouth916
ArchiveNorth723
SearchNorth662
BillingEast581
DeliveryWest440

Code

The same example in each framework; pick one once and every example on the site follows it.

tsx
import { useState } from 'react';
import { uiSortRows } from '@silverpoint/core/ui';
import { SpTable } from '@silverpoint/react/ui/table';

const columns = [
  { key: 'team', title: 'Team', sortable: true },
  { key: 'region', title: 'Region' },
  { key: 'load', title: 'Load %', align: 'end', sortable: true },
  { key: 'incidents', title: 'Incidents', align: 'end', sortable: true },
] as const;

export function Teams({ teams }: { teams: Record<string, unknown>[] }) {
  const [sortKey, setSortKey] = useState('load');
  const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');
  const sort = (key: string) => {
    setSortOrder(key === sortKey && sortOrder === 'asc' ? 'desc' : 'asc');
    setSortKey(key);
  };
  return (
    <SpTable
      caption="On-call teams"
      columns={columns}
      data={uiSortRows(teams, sortKey, sortOrder)} // the table draws rows as given
      rowKey="team"
      sortKey={sortKey}
      sortOrder={sortOrder}
      onSort={sort}
      striped
    />
  );
}

Import

Import @silverpoint/grounds/ui.css once, beside styles.css; Reflex adds it for you. Every adapter also exports it from the ui barrel.

FrameworkImport
Reactimport { SpTable } from '@silverpoint/react/ui/table';
Vueimport { SpTable } from '@silverpoint/vue/ui/table';
Angularimport { SpTable } from '@silverpoint/angular/ui/table'; · sp-table
Reflexfrom reflex_silverpoint_react import sp_table, sort_rows

Events, values and slots

Each framework's own way. A change carries the new value itself (a key, a page, a number, a bool), never a DOM event.

ReactVueAngularReflex
SortonSort(key)@sort(sort)on_sort

Props

React / AngularVueTypeDescription
columns requiredcolumnsreadonly TableColumn[]The columns, in order; each names the key it reads from a row.
data requireddatareadonly Readonly<Record<string, unknown>>[]The rows, drawn as given: the consumer sorts them.
caption captionstringThe table's <caption>, its accessible name.
sortKey sort-keystringA sortable column's key; another key sorts nothing, silently.
sortOrder sort-order'asc' | 'desc'Default 'asc'.
striped stripedbooleanDefault false.
hoverable hoverablebooleanDefault true.
bordered borderedbooleanDefault true.
emptyText empty-textstringDefault 'No data'.
rowKey row-keystringThe column whose value keys each row.

In Reflex the names are snake_case; the Reflex column of Composed components shows the builder's arguments.

Common props

Every UI component also takes these, falling back to the dashboard it sits in, then to the provider. In Reflex they read silverpoint_provider too; only sp_trigger does not: pass them to it.

React / AngularVueReflexTypeDescription
idididstrThe frame variant and every related id derive from it.
groundgroundgroundLiteral['silverpoint', 'cyanotype'] | str | dict[str, Any]Style ground: "silverpoint" or "cyanotype", or a ground object. Defaults to the dashboard's, then the provider's, or silverpoint.
substratesubstratesubstrateLiteral['cream', 'green', 'blue', 'ochre', 'prussian']Prepared substrate within the ground.
modemodemodeLiteral['ink', 'precision']ink by default; precision disables inking.
seedseedseedstr | intSeed of the frame's hand; overrides id for the frame variant only.
sizesizesizeLiteral['sm', 'md', 'lg']Control size: sm, md (default) or lg.
palettepalettepalettedict[str, str]Colours over the ground's (set with palette=), merged over the dashboard's and the provider's.
classNameclass-nameclass_namestrAdded to the component's root element, after its own classes.
palettepalettepalettePaletteColours over the ground's, merged over the dashboard's and the provider's.
Report it
Found something wrong with SpTable? Open an issue on GitHub — the form comes pre-filled with the component and the version.