Forms
Das Basis-Layout einer Gruppe von Eingabefeldern wird mit dem Grund-Markup bereitgestellt. Dieses ist immer zu verwenden und gibt eine grundlegende Formatierung und Ausrichtung der Elemente vor. Dieses Grund-Markup kann mit beliebigen Elementen aus den nachfolgenden Beispielen gefüllt werden.
Example
<form class="form--base panel--heavy">
<p class="form-description">
Hinweis: Pflichfelder sind mit einem <span class="icon-required" aria-hidden="true">*</span><span class="aural">(Pflichtfeld)</span> markiert.
</p>
<div class="form-group">
<label for="myInputField1431" class="form-label ">
Input <span class="icon-required" aria-hidden="true">*</span><span class="aural">(Pflichtfeld)</span>
</label>
<input class="form-control" required aria-required="true" id="myInputField1431" type="text" aria-describedby="myInputField1431Help " name="myInputField1431">
<small id="myInputField1431Help" class="formgroup__help">Helptext</small>
</div>
<div class="form-group">
<label for="mySelect2817" class="form-label">
Select <span class="icon-required" aria-hidden="true">*</span><span class="aural">(Pflichtfeld)</span>
</label>
<select class="form-control" required aria-required="true" id="mySelect2817" aria-describedby="mySelect2817Help " name="mySelect2817">
<option value="">Bitte wählen</option>
<option value="option1">Option1</option>
<option value="option2">Option2</option>
</select>
<small id="mySelect2817Help" class="formgroup__help">Helptext</small>
</div>
<fieldset >
<legend >
Frage
</legend>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="myCheckbox7757" name="myCheckbox7757">
<label class="form-check-label" for="myCheckbox7757">Antwort 1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="myCheckbox844" name="myCheckbox844">
<label class="form-check-label" for="myCheckbox844">Antwort 2</label>
</div>
</fieldset>
<fieldset >
<legend >
Frage
</legend>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox6235" name="exampleRadios1">
<label class="form-check-label" for="myCheckbox6235">Ja</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox8302" name="exampleRadios1">
<label class="form-check-label" for="myCheckbox8302">Nein</label>
</div>
</fieldset>
<div class="form-actions">
<div class="form-actions__left">
<a href="#randomtarget4970" class="link--back">Back</a>
</div>
<div class="form-actions__right">
<button type="submit" class="button">Action</button>
</div>
</div>
<div class="form__footer panel__footer panel--heavy">
<p>Optionaler Footer</p>
</div>
</form>
Form elements
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField8121" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField8121" type="text" name="myInputField8121">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="mySelect2652" class="form-label">
Select
</label>
<select class="form-control" id="mySelect2652" name="mySelect2652">
<option value="">Bitte wählen</option>
<option value="option1">Option1</option>
<option value="option2">Option2</option>
</select>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="mySelect8336" class="form-label">
Multiselect
</label>
<select class="form-control" multiple id="mySelect8336" name="mySelect8336">
<option value="">Bitte wählen</option>
<option value="option1">Option1</option>
<option value="option2">Option2</option>
</select>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myTextarea3206" class="form-label ">
Textarea
</label>
<textarea class="form-control" id="myTextarea3206" rows="3" name="myTextarea3206"></textarea>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField2684" class="form-label ">
Dateiupload
</label>
<input class="form-control" id="myInputField2684" type="file" name="myInputField2684">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField5994" class="form-label ">
Time
</label>
<input class="form-control" id="myInputField5994" type="time" name="myInputField5994">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField7349" class="form-label ">
Number
</label>
<input class="form-control" id="myInputField7349" type="number" name="myInputField7349">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField2253" class="form-label ">
Url
</label>
<input class="form-control" id="myInputField2253" type="url" name="myInputField2253">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField7724" class="form-label ">
Datepicker native (input[type=date])
</label>
<input class="form-control" id="myInputField7724" type="date" name="myInputField7724">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField1231" class="form-label ">
Datepicker with flatpickr.js (input.datepicker)
</label>
<input class="form-control datepicker" id="myInputField1231" type="text" name="myInputField1231">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField6808" class="form-label ">
Readonly
</label>
<input class="form-control" readonly id="myInputField6808" type="text" value="Dieser Text ist nicht zu ändern" name="myInputField6808">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField7570" class="form-label ">
Required <span class="icon-required" aria-hidden="true">*</span><span class="aural">(Pflichtfeld)</span>
</label>
<input class="form-control" required aria-required="true" id="myInputField7570" type="text" name="myInputField7570">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField5605" class="form-label ">
Input as plaintext
</label>
<input class="form-control-plaintext" readonly id="myInputField5605" type="text" value="Dieser Wert sieht aus wie Plaintext" name="myInputField5605">
</div>
</form>
Checkboxes und Radio buttons
Standardmäßig werden Checkboxen und Radios untereinander angezeigt und in der Wrapper-Klasse .form-check
gekapselt. Das Inputfeld hat die Klasse .form-check-input
. Das Label hat die Klasse .form-check-label
.
Barrierefreiheit: Bitte beachten Sie bei Eingabegruppen die Verwendung von fieldset
und legend
. Siehe auch: Barrierefreies Webdesign - Mit FIELDSET und LEGEND zu beschreibenden Formularbeschriftungen
<form class="form--base panel--heavy">
<fieldset >
<legend >
Checkboxes legend
</legend>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="myCheckbox3524" name="myCheckbox3524">
<label class="form-check-label" for="myCheckbox3524">Checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="myCheckbox2747" name="myCheckbox2747">
<label class="form-check-label" for="myCheckbox2747">Checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" disabled id="myCheckbox3194" name="myCheckbox3194">
<label class="form-check-label" for="myCheckbox3194">Disabled checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="myCheckbox6792" name="myCheckbox6792">
<label class="form-check-label" for="myCheckbox6792">Checkbox label with a lot of text Philosophy is considered a science but it is difficult to say, when one has to compare with an ordinary science, for example biology, or chemistry.</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="myCheckbox6683" name="myCheckbox6683">
<label class="form-check-label" for="myCheckbox6683">Checkbox label</label>
</div>
</fieldset>
</form>
<form class="form--base panel--heavy">
<fieldset >
<legend >
Radio button legend
</legend>
<div class="form-check">
<input class="form-check-input" type="radio" id="myCheckbox2828" name="exampleRadios">
<label class="form-check-label" for="myCheckbox2828">Radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" id="myCheckbox4570" name="exampleRadios">
<label class="form-check-label" for="myCheckbox4570">Radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" disabled id="myCheckbox7620" name="exampleRadios">
<label class="form-check-label" for="myCheckbox7620">Disabled radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" id="myCheckbox3999" name="exampleRadios">
<label class="form-check-label" for="myCheckbox3999">Radio label with a lot of text Philosophy is considered a science but it is difficult to say, when one has to compare with an ordinary science, for example biology, or chemistry.</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" id="myCheckbox7927" name="exampleRadios">
<label class="form-check-label" for="myCheckbox7927">Radio label</label>
</div>
</fieldset>
</form>
Inline Checkboxen: Checkboxen und Radios können mit der Klasse .form-check-inline
horizontal gruppiert werden.
<form class="form--base panel--heavy">
<fieldset >
<legend >
Inline checkboxes legend
</legend>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="myCheckbox2528" name="myCheckbox2528">
<label class="form-check-label" for="myCheckbox2528">Checkbox label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="myCheckbox253" name="myCheckbox253">
<label class="form-check-label" for="myCheckbox253">Checkbox label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" disabled id="myCheckbox5418" name="myCheckbox5418">
<label class="form-check-label" for="myCheckbox5418">Disabled checkbox label</label>
</div>
</fieldset>
</form>
<form class="form--base panel--heavy">
<fieldset >
<legend >
Inline radio buttons legend
</legend>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox7942" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox7942">Radio button label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox955" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox955">Radio button label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" disabled id="myCheckbox3825" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox3825">Disabled Radio button label</label>
</div>
</fieldset>
</form>
Toggle switch
<form class="form--base panel--heavy">
<fieldset >
<legend >
Settings
</legend>
<div class="toggle-switch form-check">
<input type="checkbox" name="toggle-switch-input-5477" id="toggle-switch-5477" aria-label="Toggle Switch" class="toggle-switch__input" checked="checked">
<span class="toggle-switch__display" hidden>
<i class="bicon bicon-check toggle-switch__icon toggle-switch__icon--on" aria-hidden="true"></i>
<i class="bicon bicon-times toggle-switch__icon toggle-switch__icon--off" aria-hidden="true"></i>
</span>
<label class="toggle-switch__label" for="toggle-switch-5477">Receive Notifications</label>
</div>
<div class="toggle-switch form-check">
<input type="checkbox" name="toggle-switch-input-2512" id="toggle-switch-2512" aria-label="Toggle Switch" class="toggle-switch__input">
<span class="toggle-switch__display" hidden>
<i class="bicon bicon-check toggle-switch__icon toggle-switch__icon--on" aria-hidden="true"></i>
<i class="bicon bicon-times toggle-switch__icon toggle-switch__icon--off" aria-hidden="true"></i>
</span>
<label class="toggle-switch__label" for="toggle-switch-2512">Receive SMS</label>
</div>
<div class="toggle-switch form-check">
<input type="checkbox" name="toggle-switch-input-2014" id="toggle-switch-2014" aria-label="Toggle Switch" class="toggle-switch__input" disabled="disabled">
<span class="toggle-switch__display" hidden>
<i class="bicon bicon-check toggle-switch__icon toggle-switch__icon--on" aria-hidden="true"></i>
<i class="bicon bicon-times toggle-switch__icon toggle-switch__icon--off" aria-hidden="true"></i>
</span>
<label class="toggle-switch__label" for="toggle-switch-2014">Receive call (disabled)</label>
</div>
</fieldset>
</form>
Hilfetexte
Der Hilfetext hat die Klasse .formgroup__help
. Standardmäßig wird er unterhalb des Eingabefeldes angezeigt. Für Screenreader wird das Eingabeelement über das Attribut aria-describedby
mit dem id des Beschreibungstexte verknüpft.
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField2682" class="form-label ">
Passwort
</label>
<input class="form-control" id="myInputField2682" type="password" aria-describedby="myInputField2682Help " placeholder="Geben Sie hier Ihr passwort ein" name="myInputField2682">
<small id="myInputField2682Help" class="formgroup__help">We never share your email with anyone else.</small>
</div>
</form>
Validierung
Über die Klassen .is-invalid
und .is-valid
können Elemente farblich gekennzeichnet werden.
Ein zusätzlicher Fehlertext mit der Klasse .message.message-error
bzw. .message.message-success
wird unterhalb des invaliden Elementes angezeigt.
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField282" class="form-label ">
Textfeld
</label>
<input class="form-control is-invalid" id="myInputField282" type="text" aria-describedby="myInputField282Invalid " name="myInputField282">
<div class="message message--error" id="myInputField282Invalid">
Bitte füllen Sie dieses Feld aus.
</div>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField1798" class="form-label ">
Textfeld
</label>
<input class="form-control is-valid" id="myInputField1798" type="text" aria-describedby="myInputField1798Valid " value="Ich bin ein Text" name="myInputField1798">
<div class="message message--success" id="myInputField1798Valid">
Dieses Feld ist richtig ausgefüllt.
</div>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-check">
<input class="form-check-input is-invalid" type="checkbox" aria-describedby="myCheckbox8231Invalid " id="myCheckbox8231" name="myCheckbox8231">
<label class="form-check-label" for="myCheckbox8231">Checkbox</label>
<div id="myCheckbox8231Invalid" class="message message--error">Bitte füllen Sie dieses Feld aus.</div>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-check">
<input class="form-check-input is-valid" type="checkbox" aria-describedby="myCheckbox1333Valid " id="myCheckbox1333" name="myCheckbox1333">
<label class="form-check-label" for="myCheckbox1333">Checkbox</label>
<div id="myCheckbox1333Valid" class="message message--success">Dieses Feld ist richtig ausgefüllt.</div>
</div>
</form>
Horizontale Elemente
Horizontale Darstellung von Elementen mit .form-group--inline
.
<form class="form--base panel--heavy">
<div class="form-group form-group form-group--inline"> <div class="form-group">
<label for="myInputField2819" class="form-label aural">
Textfeld
</label>
<input class="form-control" id="myInputField2819" type="text" name="myInputField2819">
</div>
<div class="form-group">
<label for="mySelect5058" class="form-label aural">
Auswahlliste
</label>
<select class="form-control" id="mySelect5058" name="mySelect5058">
<option value="">Bitte wählen</option>
<option value="option1">Option1</option>
<option value="option2">Option2</option>
</select>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="myCheckbox9271" name="myCheckbox9271">
<label class="form-check-label" for="myCheckbox9271">Checkbox</label>
</div>
<button type="submit" class="button">Button</button>
</div></form>
.form-group--inline
.fullspace
.align-bottom
<form class="form--base panel--heavy">
<div class="form-group form-group form-group--inline fullspace align-bottom"> <div class="form-group">
<label for="myInputField1604" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField1604" type="text" name="myInputField1604">
</div>
<div class="form-group">
<label for="myInputField7539" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField7539" type="text" name="myInputField7539">
</div>
<button type="submit" class="button">Button</button>
</div></form>