Skip to content

Machine-translated – improvements welcome. Suggest an improvement

Table

Tabelle (#1030) shows rows with columns; each row leads to a page – usually a folder. When wide it is a table, when narrow (on a phone or in a narrow column) a list with the first two columns, like the result lists in the Library. Without rows it shows a quiet sentence instead of an empty table. Used by the field kind Table in the folder (web/src/ablage/Tabellenfeld.tsx).

What it is for

For a short list of entries with several details per entry, where every row leads to a page (items of an invoice, linked folders). No sorting, no totals and no editing in the row: that is left to the page behind it. Rows to select get a selection checkbox; a searchable list uses the Search.

Matching patterns in the pattern catalogue: C8 · A link goes somewhere else, a button does something, C11 · Links as sections with a count, D6 · On the phone.

How to use it

With How it works
Mouse A click anywhere in the row opens its target; the row under the mouse gets a surface, the link in the first column is underlined.
Keyboard Tab reaches the link in the first column of each row; Enter opens it. Buttons in the footer (“+ Item”) follow after that.
Touch When narrow every row is a list entry; the links are at least 44 px high (On a phone).

What it means

Every row is a way to a page. Numbers and amounts are right-aligned. If the table is empty, a quiet sentence says what is missing (“No items yet”) – no empty table with column headers. When narrow the list only shows the first two columns; everything else is on the page behind it.

States

State How it comes about How it looks
wide own frame from breitAb (default 480 px or 110 px per column) table with column headers
narrow own frame narrower list with the first two columns
empty no zeilen the sentence from leer
row under the mouse – surface --senke, link underlined
keyboard focus – 2 px ring in --akzent on the link

Section “Table” of the pattern page: wide, narrow and empty

Section “Table” dark

Accessibility

  • Table or list carry beschriftung as aria-label (“Items”).
  • The first column is the link (keyboard, screen readers); the click on the whole row is only a shortcut for the mouse – nobody depends on it.
  • When wide it is a real <table> with column headers, when narrow a <ul>.

Code

import { Knopf, Tabelle } from '../bausteine';

<Tabelle beschriftung={t('…positionen')} spalten={spalten} zeilen={zeilen} leer={t('…noch-keine')}
  fuss={<Knopf art="anlegen" groesse="klein" onClick={neu}>{t('…neu')}</Knopf>} />
Prop Purpose
beschriftung name for screen readers, e.g. “Items” (aria-label on the table or list)
spalten { key, titel, rechts? } – rechts for numbers and amounts
zeilen { key, ziel, zellen, ersatz } – ziel is a path in Ablago; ersatz is shown in the first column when it is empty
leer sentence without rows, e.g. “No items yet”
fuss below the rows, e.g. “+ Item” and “Show more”
breitAb from this width on a table; default 480 px or 110 px per column
  • The component measures narrow or wide itself (ResizeObserver on its own frame) – not the width of the window.
  • No sorting, no totals and no editing in the row: that is left to the page behind it.

Files and tests

  • Component: web/src/bausteine/tabelle/Tabelle.tsx, look: Tabelle.module.css
  • Pattern page: web/src/bausteine/tabelle/muster.tsx – section Table: wide, narrow and empty
  • First user: web/src/ablage/Tabellenfeld.tsx (field kind Table)