Skip to content

Machine-translated – improvements welcome. Suggest an improvement

Selection checkbox

Wahlhaken (#1211, #1212) is the checkbox that selects rows of a list – folders of a view, documents of a folder, entries in the bin. It sits in the row without a visible label; the row shows what it is about.

What it is for

For selecting rows, to then do something with all selected ones (move, delete, download). For a checkbox with a visible label – an option, a confirmation – there is HakenFeld (Field); for something that is on or off, the Switch.

Matching patterns in the pattern catalogue: A2 · Multi-select, A7 · Switch or checkbox, D6 · On the phone.

How to use it

With How it works
Mouse A click sets or clears the tick. With Shift held, a click selects all rows from the last choice up to here. A click on the checkbox doesn't open the row – even if the whole row is clickable. The checkbox in the header of the list selects all or none.
Keyboard Tab reaches the checkbox, Space sets or clears it.
Touch Touch target at least 24 px on the computer, 44 × 44 px around the box on the phone (pointer: coarse).

What it means

Tick – this row is selected. Empty – not selected. Dash in the header of the list (“partial”) – some are selected, not all. Faded – this row can't be selected right now (e.g. a document that goes away on saving).

States

State How it comes about How it looks
on an tick set
off an={false} empty box
partial teilweise dash instead of tick (indeterminate)
mouse over – soft ring (--akzent-zart)
keyboard focus – 2 px ring in --akzent
locked gesperrt faded, not selectable

“Selection checkbox” section of the pattern page: on, off, partial, disabled

“Selection checkbox” section, dark

Accessibility

A real <input type="checkbox">: screen readers say “checkbox, Select tenancy agreement, checked”. Because no label is visible, beschriftung is required and names the entry. “Partial” is announced as “mixed” (indeterminate). Locked is disabled.

Code

<Wahlhaken an={gewaehlt.has(x.id)} beschriftung={t('…auswaehlen', { name: x.name })}
  setze={(an, bereich) => waehle(x, an, bereich)} />
Prop Purpose
an selected or not
setze(an, bereich) new state; bereich is true with Shift held (from the last choice up to here)
beschriftung name for screen readers naming the entry (“Select tenancy agreement”)
teilweise “some selected” – for the checkbox in the header of a list (indeterminate)
gesperrt not selectable (e.g. a document that goes away on saving)

Files and tests

  • Building block: web/src/bausteine/wahlhaken/Wahlhaken.tsx, look: Wahlhaken.module.css
  • Pattern page: web/src/bausteine/wahlhaken/muster.tsx – section Selection checkbox: on, off, partly and locked