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="myInputField8809" 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="myInputField8809" type="text" aria-describedby="myInputField8809Help " name="myInputField8809">
<small id="myInputField8809Help" class="formgroup__help">Helptext</small>
</div>
<div class="form-group">
<label for="mySelect5539" 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="mySelect5539" aria-describedby="mySelect5539Help " name="mySelect5539">
<option value="">Bitte wählen</option>
<option value="option1">Option1</option>
<option value="option2">Option2</option>
</select>
<small id="mySelect5539Help" 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="myCheckbox3728" name="myCheckbox3728">
<label class="form-check-label" for="myCheckbox3728">Antwort 1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="myCheckbox8363" name="myCheckbox8363">
<label class="form-check-label" for="myCheckbox8363">Antwort 2</label>
</div>
</fieldset>
<fieldset >
<legend >
Frage
</legend>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox7559" name="exampleRadios1">
<label class="form-check-label" for="myCheckbox7559">Ja</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox7220" name="exampleRadios1">
<label class="form-check-label" for="myCheckbox7220">Nein</label>
</div>
</fieldset>
<div class="form-actions">
<div class="form-actions__left">
<a href="#randomtarget5792" 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="myInputField4877" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField4877" type="text" name="myInputField4877">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="mySelect999" class="form-label">
Select
</label>
<select class="form-control" id="mySelect999" name="mySelect999">
<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="mySelect5299" class="form-label">
Multiselect
</label>
<select class="form-control" multiple id="mySelect5299" name="mySelect5299">
<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="myTextarea3259" class="form-label ">
Textarea
</label>
<textarea class="form-control" id="myTextarea3259" rows="3" name="myTextarea3259"></textarea>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField8839" class="form-label ">
Dateiupload
</label>
<input class="form-control" id="myInputField8839" type="file" name="myInputField8839">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField3752" class="form-label ">
Time
</label>
<input class="form-control" id="myInputField3752" type="time" name="myInputField3752">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField2722" class="form-label ">
Number
</label>
<input class="form-control" id="myInputField2722" type="number" name="myInputField2722">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField3842" class="form-label ">
Url
</label>
<input class="form-control" id="myInputField3842" type="url" name="myInputField3842">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField7934" class="form-label ">
Datepicker native (input[type=date])
</label>
<input class="form-control" id="myInputField7934" type="date" name="myInputField7934">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField1509" class="form-label ">
Datepicker with flatpickr.js (input.datepicker)
</label>
<input class="form-control datepicker" id="myInputField1509" type="text" name="myInputField1509">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField6030" class="form-label ">
Readonly
</label>
<input class="form-control" readonly id="myInputField6030" type="text" value="Dieser Text ist nicht zu ändern" name="myInputField6030">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField8737" 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="myInputField8737" type="text" name="myInputField8737">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField4515" class="form-label ">
Input as plaintext
</label>
<input class="form-control-plaintext" readonly id="myInputField4515" type="text" value="Dieser Wert sieht aus wie Plaintext" name="myInputField4515">
</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="myCheckbox9606" name="myCheckbox9606">
<label class="form-check-label" for="myCheckbox9606">Checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="myCheckbox6545" name="myCheckbox6545">
<label class="form-check-label" for="myCheckbox6545">Checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" disabled id="myCheckbox7428" name="myCheckbox7428">
<label class="form-check-label" for="myCheckbox7428">Disabled checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="myCheckbox2298" name="myCheckbox2298">
<label class="form-check-label" for="myCheckbox2298">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="myCheckbox7423" name="myCheckbox7423">
<label class="form-check-label" for="myCheckbox7423">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="myCheckbox4043" name="exampleRadios">
<label class="form-check-label" for="myCheckbox4043">Radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" id="myCheckbox8441" name="exampleRadios">
<label class="form-check-label" for="myCheckbox8441">Radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" disabled id="myCheckbox7531" name="exampleRadios">
<label class="form-check-label" for="myCheckbox7531">Disabled radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" id="myCheckbox1069" name="exampleRadios">
<label class="form-check-label" for="myCheckbox1069">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="myCheckbox6116" name="exampleRadios">
<label class="form-check-label" for="myCheckbox6116">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="myCheckbox6957" name="myCheckbox6957">
<label class="form-check-label" for="myCheckbox6957">Checkbox label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="myCheckbox1975" name="myCheckbox1975">
<label class="form-check-label" for="myCheckbox1975">Checkbox label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" disabled id="myCheckbox1436" name="myCheckbox1436">
<label class="form-check-label" for="myCheckbox1436">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="myCheckbox4420" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox4420">Radio button label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox9756" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox9756">Radio button label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" disabled id="myCheckbox6380" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox6380">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-177" id="toggle-switch-177" 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-177">Receive Notifications</label>
</div>
<div class="toggle-switch form-check">
<input type="checkbox" name="toggle-switch-input-9584" id="toggle-switch-9584" 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-9584">Receive SMS</label>
</div>
<div class="toggle-switch form-check">
<input type="checkbox" name="toggle-switch-input-4232" id="toggle-switch-4232" 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-4232">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="myInputField8677" class="form-label ">
Passwort
</label>
<input class="form-control" id="myInputField8677" type="password" aria-describedby="myInputField8677Help " placeholder="Geben Sie hier Ihr passwort ein" name="myInputField8677">
<small id="myInputField8677Help" 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="myInputField9016" class="form-label ">
Textfeld
</label>
<input class="form-control is-invalid" id="myInputField9016" type="text" aria-describedby="myInputField9016Invalid " name="myInputField9016">
<div class="message message--error" id="myInputField9016Invalid">
Bitte füllen Sie dieses Feld aus.
</div>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField6919" class="form-label ">
Textfeld
</label>
<input class="form-control is-valid" id="myInputField6919" type="text" aria-describedby="myInputField6919Valid " value="Ich bin ein Text" name="myInputField6919">
<div class="message message--success" id="myInputField6919Valid">
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="myCheckbox5952Invalid " id="myCheckbox5952" name="myCheckbox5952">
<label class="form-check-label" for="myCheckbox5952">Checkbox</label>
<div id="myCheckbox5952Invalid" 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="myCheckbox896Valid " id="myCheckbox896" name="myCheckbox896">
<label class="form-check-label" for="myCheckbox896">Checkbox</label>
<div id="myCheckbox896Valid" 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="myInputField9995" class="form-label aural">
Textfeld
</label>
<input class="form-control" id="myInputField9995" type="text" name="myInputField9995">
</div>
<div class="form-group">
<label for="mySelect3848" class="form-label aural">
Auswahlliste
</label>
<select class="form-control" id="mySelect3848" name="mySelect3848">
<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="myCheckbox2298" name="myCheckbox2298">
<label class="form-check-label" for="myCheckbox2298">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="myInputField9168" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField9168" type="text" name="myInputField9168">
</div>
<div class="form-group">
<label for="myInputField5217" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField5217" type="text" name="myInputField5217">
</div>
<button type="submit" class="button">Button</button>
</div></form>