Skip to content

Machine-translated – improvements welcome. Suggest an improvement

Tabs

Reiter (tabs) is the building block for tabs above some content (#1210): exactly one tab is active, its content stands below it (ReiterFlaeche). There is one active look for all places – surface like the content, border, a line in the accent colour on top (blue also means selection, principle 1). Before, the active tab in a folder (coloured line per kind) looked different from the one in text recognition (grey).

What it is for

For different content in the same place that you switch between – such as the fields and documents of a folder.

Distinction: the toggle changes how the same thing works (e.g. “List · Month · Year”); tabs show different content. For areas below each other that you expand and collapse there are Areas.

Matching patterns in the pattern catalogue: C10 · Same things the same: repeat patterns, do not reinvent them, C11 · Links as sections with a count, C17 · Segmented control for two to four equal choices.

How to use it

With How it works
Mouse A click on a tab shows its content. If not all tabs fit the width, the row scrolls sideways – the page does not.
Keyboard Following WAI-ARIA: Tab only reaches the active tab, the arrow keys (also Home/End) choose the next one; Tab moves on to the first control in the panel.
Touch Every tab is at least 44 px high; the row can be swiped sideways (On a phone).

What it means

The active tab has the surface of the content, a border and a blue line on top – it visibly belongs to the content below. The others stand quietly without a surface. A quiet number (anzahl) says how much is in it; a red number (fehler) says that something in it is wrong.

States

State How it comes about How it looks
active wert surface --flaeche, border --linie, 3 px --akzent on top, text --tinte
not active – no surface, text --leise
mouse over – text --tinte, surface --senke (not on the active one)
keyboard focus – 2 px ring in --akzent inside
with a count anzahl quiet number on --senke, on the active one on --akzent-zart
with errors fehler red number on --schlecht-zart

“Tabs” section of the pattern page: tabs of a folder with errors and a count

“Tabs” section, dark

Accessibility

  • Screen readers: role="tablist" with a name, per tab role="tab" with aria-selected and aria-controls; the panel is role="tabpanel" and named after the active tab (no tabindex of its own: its content has controls).
  • The red error number has a text for screen readers, not only the colour.
  • Wider than the space: the row scrolls sideways, the page does not. On a phone every tab is at least 44 px high.

Code

import { Reiter, ReiterFlaeche } from '../bausteine';

const [reiter, setReiter] = useState<'felder' | 'dokumente'>('felder');
<Reiter id="mappe" wert={reiter} setze={setReiter} beschriftung={t('…register-der-mappe')}
  wahlen={[{ wert: 'felder', text: t('…felder'), fehler: 2 }, { wert: 'dokumente', text: t('…dokumente'), anzahl: 3 }]} />
<ReiterFlaeche id="mappe" wert={reiter}>{inhalt}</ReiterFlaeche>
Property Meaning
id identifier of the row; the id of the tabs (reiterId) and of the panel (flaecheId) derive from it
wert, setze the active tab and switching
wahlen per tab { wert, text, anzahl?, fehler?, anker? } – fehler shows a red number (with text for screen readers), anzahl a quiet one
beschriftung name of the row for screen readers

Existing code

The tabs of a folder (.registertab) and of text recognition move to this building block in #1211 and #1213.

Files and tests

  • Building block: web/src/bausteine/reiter/Reiter.tsx, look: Reiter.module.css
  • Pattern page: web/src/bausteine/reiter/muster.tsx
  • Test: web/test/baustein-reiter.test.ts