Skip to content

Machine-translated – improvements welcome. Suggest an improvement

Expander

Aufklapper is the heading of a section or the row of a list that expands and collapses content (#1270): arrow to the right (closed) or down (open), label left-aligned and wrapping, a light background on hover. The component brings the arrow, aria-expanded and aria-controls; the caller shows the content below. These used to be the special forms aufklappkopf and aufklappzeile on the button.

What it is for

Rule: a section that expands and collapses uses this component – such as the expert mode of the packages or a database measurement. For several areas of a page with a jump bar there are Areas; for different content in the same place, Tabs.

Matching patterns in the pattern catalogue: C13 · Special cases as a collapsed group at the top, C15 · Editor on the right: jump bar + sections, C8 · A link goes somewhere else, a button does something.

How to use it

With How it works
Mouse A click on the heading or row expands or collapses the content; on hover it gets a light background.
Keyboard Tab reaches the expander, Enter or Space expand and collapse.
Touch The expander is a button (special form) with the touch area of a button (44 px high).

What it means

Arrow to the right – there is more here, collapsed. Arrow down – expanded, the content is below. The heading of a section (kopf) is bold with the arrow in the accent colour; the row of a list (zeile) has the list font and a quiet arrow.

States

State How it comes about How it looks
closed offen={false} arrow to the right
open offen arrow down, content visible at the caller
heading form="kopf" (default) bold, full width, arrow in --akzent
row form="zeile" list font, quiet arrow
mouse over – light background
keyboard focus – ring as for the button

“Expander” section of the pattern page: heading of a section (expanded) and row of a list

“Expander” section, dark

Accessibility

The expander is a <button> (Knopf art="eigen") with aria-expanded and aria-controls pointing to the id of the content (steuert) – screen readers say “collapsed” or “expanded”. The arrow is decoration only. The content needs the id given in steuert.

Code

import { Aufklapper } from '../bausteine';

<section className="aufklappbereich">
  <Aufklapper offen={experte} steuert="pakete-experte" umschalten={() => setExperte(!experte)}>
    <span>{t('werkbank.pakete.expertenmodus')}</span>
    <span className="leise klein">{t('werkbank.pakete.weitere-quellen-paket-oder')}</span>
  </Aufklapper>
  {experte && <div id="pakete-experte" className="aufklappinhalt">…</div>}
</section>

// Row of a list, e.g. a database measurement:
<Aufklapper form="zeile" offen={offenHier} umschalten={() => umschalten(id)}>…</Aufklapper>
Property Meaning
form kopf (default: bold, full width, arrow in accent colour) or zeile (list font, quiet arrow)
offen, umschalten state and toggle – the state stays with the caller
steuert id of the content (aria-controls)
title tooltip

Files and tests

  • Component: web/src/bausteine/aufklapper/Aufklapper.tsx, look: Aufklapper.module.css
  • Pattern page: web/src/bausteine/aufklapper/muster.tsx
  • Test: web/test/baustein-etikett.test.ts (together with the tag)