Machine-translated – improvements welcome. Suggest an improvement
Toggle¶
Umschalter (#1002) is a segmented button: two to four equal choices side by side, exactly one is on. It changes how something works – for example “Ask · Tips · Manual” in the assistant at the bottom right (web/src/begleiter/Begleiter.tsx, #1219) or “List · Month · Year” in To do.
What it is for¶
For two to four equal choices of which exactly one applies, and which change how the same thing works or looks. For tabs with their own content below them (the tabs of a folder) there are the tab cards (Tabs). Something that is on or off is a Switch.
Matching patterns in the pattern catalogue: C17 · Segmented control for two to four equal choices, D6 · On the phone.
How to use it¶
| With | How it works |
|---|---|
| Mouse | A click on a choice chooses it; the chosen one stays calm, the others get a surface on hover. |
| Keyboard | As with radio buttons: Tab only reaches the chosen choice; the arrow keys (left/right and up/down, wrapping round) as well as Home and End choose and stay in the group; Tab moves on. |
| Touch | Each choice is at least 44 × 44 px (On the phone). Long choices are stacked on a phone with schmalUntereinander, as wide as the column. |
What it means¶
- Chosen is not shown by colour alone: filled, bold and with a border in the accent colour. The bold type doesn’t change the width (#1175): invisibly, each choice keeps room for its bold text – nothing jumps when switching.
- Unobtrusive: small type, quiet colour – it sits next to a box without looking like a main action.
- Remembering is up to the page (e.g. as a setting of the person with
d.setzeEinstellung).
States¶
| State | How it comes about | How it looks |
|---|---|---|
| chosen | wert |
surface --akzent-zart, border --akzent, bold |
| not chosen | – | no surface, text --leise |
| mouse over | – | text --tinte, surface --senke (not on the chosen one) |
| keyboard focus | – | 2 px ring in --akzent |
| two, three choices | wahlen |
side by side |
| long choices on a phone | schmalUntereinander |
stacked, as wide as the column |
Accessibility¶
- For screen readers a group of radio buttons (
role="radiogroup"with the label, each choicerole="radio"witharia-checked) – it announces what is chosen. - Keyboard as with radio buttons (see above); only the chosen choice is a Tab stop.
- The chosen choice is not shown by colour alone (border and bold type).
Code¶
import { Umschalter } from '../bausteine';
<Umschalter wert={art} setze={waehle} beschriftung={t('ablage.startfeld.art')}
wahlen={[{ wert: 'fragen', text: t('ablage.startfeld.fragen') }, { wert: 'suchen', text: t('ablage.startfeld.suchen') }]} />
| Property | Purpose |
|---|---|
wert |
the chosen choice |
setze(wert) |
is called with the new choice – by click, tap or arrow key |
wahlen |
{ wert, text } – two to four, short (one word) |
beschriftung |
name of the group for screen readers, e.g. “Ask or search” |
anker |
jump target for tours and tips (data-anker), optional |
schmalUntereinander |
long choices (#1217, “New folder · Existing folder · Just mark as done”): stacked on a phone (up to 600 px) instead of cut off, optional |
Long choices don’t fit side by side on a phone; with schmalUntereinander they are stacked there, as wide as the column (example: “Where does this belong?” on Take over document, web/src/ablage/WohinGehoert.tsx).
Existing code¶
Older places with the class segmente in web/src/stile/ (List · Month · Year in To do, text size in My account) are converted by whoever changes them anyway.
Files and tests¶
- Building block:
web/src/bausteine/umschalter/Umschalter.tsx, look:Umschalter.module.css - Pattern page:
web/src/bausteine/umschalter/muster.tsx– section Toggle: two and three choices, plus long choices that are stacked on a phone - Test:
web/test/baustein-umschalter.test.ts

