Configurator
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" hint="Bitte gib deinen Namen so an wie im Personalausweis." oc-aria-label="Name"><oc-text-field-v1 autocomplete="given-name" style="width:10rem;min-width:0">Vorname</oc-text-field-v1><oc-text-field-v1 autocomplete="family-name" style="width:10rem;min-width:0">Nachname</oc-text-field-v1></oc-form-group-v1>Usage
Variants
You can use form group with the following form components:
Radio buttons
Checkboxes
Text field and dropdown
Text areas
HTML
<p class="demo-label">Radio buttons</p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="shrink" hint="Hinweis" oc-aria-label="Versandart" style="max-width:20rem">
<oc-radio-button-v2 width-behavior="fit"><input type="radio" name="fg-var-rb" aria-label="oc-auto"><label slot="label">Option 1</label></oc-radio-button-v2>
<oc-radio-button-v2 width-behavior="fit"><input type="radio" name="fg-var-rb" aria-label="oc-auto"><label slot="label">Option 2</label></oc-radio-button-v2>
<oc-radio-button-v2 width-behavior="fit"><input type="radio" name="fg-var-rb" aria-label="oc-auto"><label slot="label">Option 3</label></oc-radio-button-v2>
<oc-radio-button-v2 width-behavior="fit"><input type="radio" name="fg-var-rb" aria-label="oc-auto"><label slot="label">Option 4</label></oc-radio-button-v2>
</oc-form-group-v1>
<p class="demo-label">Checkboxes</p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="shrink" hint="Hinweis" oc-aria-label="Farbe" style="max-width:20rem">
<oc-checkbox-v2 width-behavior="fit"><input type="checkbox" aria-label="oc-auto"><label slot="label">Option 1</label></oc-checkbox-v2>
<oc-checkbox-v2 width-behavior="fit"><input type="checkbox" aria-label="oc-auto"><label slot="label">Option 2</label></oc-checkbox-v2>
<oc-checkbox-v2 width-behavior="fit"><input type="checkbox" aria-label="oc-auto"><label slot="label">Option 3</label></oc-checkbox-v2>
<oc-checkbox-v2 width-behavior="fit"><input type="checkbox" aria-label="oc-auto"><label slot="label">Option 4</label></oc-checkbox-v2>
</oc-form-group-v1>
<p class="demo-label">Text field and dropdown</p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" hint="Hinweis" oc-aria-label="Telefon">
<oc-text-field-v1 type="tel">Telefonnummer</oc-text-field-v1>
<oc-dropdown-v1 label="Art" empty-option><option>Mobil</option><option>Festnetz</option></oc-dropdown-v1>
</oc-form-group-v1>
<p class="demo-label">Text areas</p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" hint="Hinweis" oc-aria-label="Bewertung">
<oc-text-area-v1>Das gefällt mir</oc-text-area-v1>
<oc-text-area-v1>Das gefällt mir nicht</oc-text-area-v1>
</oc-form-group-v1>
The components of the cluster form can also be combined within the form group. For example, a text field can be combined with a dropdown.
HTML
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" hint="Hinweis" oc-aria-label="Telefon">
<oc-text-field-v1 type="tel">Telefonnummer</oc-text-field-v1>
<oc-dropdown-v1 label="Art" empty-option><option>Mobil</option><option>Festnetz</option></oc-dropdown-v1>
</oc-form-group-v1>
You can optionally extend the form group with a error or a hint. The hint helps the user filling out the form group correctly and provides further context. The error is shown additionally above the hint if the user made a wrong input. It helps the user understanding the mistake and fixing the input.
Hint
Error and hint
HTML
<p class="demo-label">Hint</p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" hint="Bitte gib deinen Namen an, wie im Personalausweis." oc-aria-label="Name">
<oc-text-field-v1>Vorname</oc-text-field-v1>
<oc-text-field-v1>Nachname</oc-text-field-v1>
</oc-form-group-v1>
<p class="demo-label">Error and hint</p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" hint="Bitte gib deinen Namen an, wie im Personalausweis." validation-message="Der eingegebene Text ist kein Name. Bitte korrigiere deine Eingabe." oc-aria-label="Name">
<oc-text-field-v1>Vorname</oc-text-field-v1>
<oc-text-field-v1>Nachname</oc-text-field-v1>
</oc-form-group-v1>
Behavior
Fitting
The components within the form group can either grow or shrink. For grow, the components will expand to fill the available space. Meanwhile, for shrink, the components will reduce their size to fit.
flex-behavior grow
flex-behavior shrink
HTML
<p class="demo-label">flex-behavior grow</p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" hint="Hinweis" oc-aria-label="Name">
<oc-text-field-v1>Vorname</oc-text-field-v1>
<oc-text-field-v1>Nachname</oc-text-field-v1>
</oc-form-group-v1>
<p class="demo-label">flex-behavior shrink</p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="shrink" gap="var(--oc-base-dimension-8)" hint="Hinweis" oc-aria-label="Name">
<oc-text-field-v1>Vorname</oc-text-field-v1>
<oc-text-field-v1>Nachname</oc-text-field-v1>
</oc-form-group-v1>
Placement
You can arrange the components within the form group either vertically or horizontally. Horizontal placement is particularly useful as it allows the hint and/or error to stretch across the full width. The gap can be customized. For text field for example you should at least use 8 px or for checkbox you should use at least 24px.
Horizontal, 24px gap
Vertical, 24px gap
HTML
<p class="demo-label">Horizontal, 24px gap</p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="shrink" gap="var(--oc-base-dimension-24)" hint="Hinweis" oc-aria-label="Versandart">
<oc-radio-button-v2 width-behavior="fit"><input type="radio" name="fg-place" aria-label="oc-auto"><label slot="label">Option 1</label></oc-radio-button-v2>
<oc-radio-button-v2 width-behavior="fit"><input type="radio" name="fg-place" aria-label="oc-auto"><label slot="label">Option 2</label></oc-radio-button-v2>
</oc-form-group-v1>
<p class="demo-label">Vertical, 24px gap</p>
<oc-form-group-v1 orientation="vertical" gap="var(--oc-base-dimension-24)" hint="Hinweis" oc-aria-label="Farbe">
<oc-checkbox-v2><input type="checkbox" aria-label="oc-auto"><label slot="label">Option 1</label></oc-checkbox-v2>
<oc-checkbox-v2><input type="checkbox" aria-label="oc-auto"><label slot="label">Option 2</label></oc-checkbox-v2>
</oc-form-group-v1>
Best practices
Name
Geburtstag
Accessibility
You can create one shared aria-label for the different components of the form group. This label is used by screen readers and should describe the form group's overall content or purpose. For example, for a form group that allows you to configure your birthday, you should create an Aria label such as "Geburtstag". The advantage is that the screen reader will not only read out the individual components, such as "Tag", "Monat" and "Jahr", but also summarise them as "Geburtstag".
Geburtstag
- oc-aria-label="Geburtstag" names the whole group for screen readers
HTML
<div class="anatomy" style="display:block;width:max-content;margin:28px auto">
<p class="demo-title">Geburtstag</p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="shrink" gap="var(--oc-base-dimension-8)" hint="Hinweis" oc-aria-label="Geburtstag">
<oc-dropdown-v1 label="Tag" empty-option style="width:6rem"><option>1</option><option>2</option><option>3</option></oc-dropdown-v1>
<oc-dropdown-v1 label="Monat" empty-option style="width:10rem"><option>Januar</option><option>Februar</option><option>März</option></oc-dropdown-v1>
<oc-dropdown-v1 label="Jahr" empty-option style="width:7rem"><option>1990</option><option>1991</option><option>1992</option></oc-dropdown-v1>
</oc-form-group-v1>
<span class="anatomy-pin" style="left:50%;top:calc(100% + 16px)">1</span>
<ol class="anatomy-key"><li data-n="1">oc-aria-label="Geburtstag" names the whole group for screen readers</li></ol>Related components
Implementation
Live demo
Neue Lieferadresse
Wir liefern an Haus- und Packstation-Adressen in Deutschland.
HTML
<div style="max-width:520px;margin:0 auto;display:grid;gap:24px">
<div style="display:grid;gap:4px">
<p class="oc-headline-100">Neue Lieferadresse</p>
<p class="oc-copy-100 oc-text-color-secondary">Wir liefern an Haus- und Packstation-Adressen in Deutschland.</p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" oc-aria-label="Name">
<oc-text-field-v1 value="Lara" autocomplete="given-name">Vorname</oc-text-field-v1>
<oc-text-field-v1 value="Lavendel" autocomplete="family-name">Nachname</oc-text-field-v1>
</oc-form-group-v1>
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" oc-aria-label="Straße und Hausnummer">
<oc-text-field-v1 value="Werner-Otto-Straße" autocomplete="address-line1">Straße</oc-text-field-v1>
<oc-text-field-v1 value="1–7" style="flex:0 1 7rem;min-width:0">Nr.</oc-text-field-v1>
</oc-form-group-v1>
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" validation-message="Die Postleitzahl passt nicht zum Ort. Bitte prüfe deine Eingabe." oc-aria-label="Postleitzahl und Ort">
<oc-text-field-v1 type="integer" value="22197" maxlength="5" hide-counter autocomplete="postal-code" style="flex:0 1 8rem;min-width:0">PLZ</oc-text-field-v1>
<oc-text-field-v1 value="Hamburg" autocomplete="address-level2">Ort</oc-text-field-v1>
</oc-form-group-v1>
<oc-checkbox-v2><input type="checkbox" checked aria-label="oc-auto"><label slot="label">Als Standard-Lieferadresse speichern</label></oc-checkbox-v2>
<oc-button-v1 variant="secondary">Abbrechen</oc-button-v1>
<oc-button-v1 variant="primary">Adresse speichern</oc-button-v1>