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="myInputField6246" 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="myInputField6246" type="text" aria-describedby="myInputField6246Help " name="myInputField6246">
<small id="myInputField6246Help" class="formgroup__help">Helptext</small>
</div>
<div class="form-group">
<label for="mySelect1587" 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="mySelect1587" aria-describedby="mySelect1587Help " name="mySelect1587">
<option value="">Bitte wählen</option>
<option value="option1">Option1</option>
<option value="option2">Option2</option>
</select>
<small id="mySelect1587Help" 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="myCheckbox8753" name="myCheckbox8753">
<label class="form-check-label" for="myCheckbox8753">Antwort 1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="myCheckbox4110" name="myCheckbox4110">
<label class="form-check-label" for="myCheckbox4110">Antwort 2</label>
</div>
</fieldset>
<fieldset >
<legend >
Frage
</legend>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox1361" name="exampleRadios1">
<label class="form-check-label" for="myCheckbox1361">Ja</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox3362" name="exampleRadios1">
<label class="form-check-label" for="myCheckbox3362">Nein</label>
</div>
</fieldset>
<div class="form-actions">
<div class="form-actions__left">
<a href="#randomtarget2782" 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="myInputField1993" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField1993" type="text" name="myInputField1993">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="mySelect2602" class="form-label">
Select
</label>
<select class="form-control" id="mySelect2602" name="mySelect2602">
<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="mySelect4268" class="form-label">
Multiselect
</label>
<select class="form-control" multiple id="mySelect4268" name="mySelect4268">
<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="myTextarea3491" class="form-label ">
Textarea
</label>
<textarea class="form-control" id="myTextarea3491" rows="3" name="myTextarea3491"></textarea>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField7610" class="form-label ">
Dateiupload
</label>
<input class="form-control" id="myInputField7610" type="file" name="myInputField7610">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField1994" class="form-label ">
Time
</label>
<input class="form-control" id="myInputField1994" type="time" name="myInputField1994">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField3020" class="form-label ">
Number
</label>
<input class="form-control" id="myInputField3020" type="number" name="myInputField3020">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField1354" class="form-label ">
Url
</label>
<input class="form-control" id="myInputField1354" type="url" name="myInputField1354">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField9277" class="form-label ">
Datepicker native (input[type=date])
</label>
<input class="form-control" id="myInputField9277" type="date" name="myInputField9277">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField6180" class="form-label ">
Datepicker with flatpickr.js (input.datepicker)
</label>
<input class="form-control datepicker" id="myInputField6180" type="text" name="myInputField6180">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField9208" class="form-label ">
Readonly
</label>
<input class="form-control" readonly id="myInputField9208" type="text" value="Dieser Text ist nicht zu ändern" name="myInputField9208">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField6684" 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="myInputField6684" type="text" name="myInputField6684">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField5699" class="form-label ">
Input as plaintext
</label>
<input class="form-control-plaintext" readonly id="myInputField5699" type="text" value="Dieser Wert sieht aus wie Plaintext" name="myInputField5699">
</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="myCheckbox8445" name="myCheckbox8445">
<label class="form-check-label" for="myCheckbox8445">Checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="myCheckbox2341" name="myCheckbox2341">
<label class="form-check-label" for="myCheckbox2341">Checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" disabled id="myCheckbox3096" name="myCheckbox3096">
<label class="form-check-label" for="myCheckbox3096">Disabled checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="myCheckbox170" name="myCheckbox170">
<label class="form-check-label" for="myCheckbox170">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="myCheckbox3071" name="myCheckbox3071">
<label class="form-check-label" for="myCheckbox3071">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="myCheckbox9446" name="exampleRadios">
<label class="form-check-label" for="myCheckbox9446">Radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" id="myCheckbox4587" name="exampleRadios">
<label class="form-check-label" for="myCheckbox4587">Radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" disabled id="myCheckbox347" name="exampleRadios">
<label class="form-check-label" for="myCheckbox347">Disabled radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" id="myCheckbox9302" name="exampleRadios">
<label class="form-check-label" for="myCheckbox9302">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="myCheckbox6189" name="exampleRadios">
<label class="form-check-label" for="myCheckbox6189">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="myCheckbox5877" name="myCheckbox5877">
<label class="form-check-label" for="myCheckbox5877">Checkbox label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="myCheckbox7632" name="myCheckbox7632">
<label class="form-check-label" for="myCheckbox7632">Checkbox label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" disabled id="myCheckbox7665" name="myCheckbox7665">
<label class="form-check-label" for="myCheckbox7665">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="myCheckbox7310" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox7310">Radio button label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox7443" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox7443">Radio button label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" disabled id="myCheckbox3660" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox3660">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-4872" id="toggle-switch-4872" 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-4872">Receive Notifications</label>
</div>
<div class="toggle-switch form-check">
<input type="checkbox" name="toggle-switch-input-9556" id="toggle-switch-9556" 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-9556">Receive SMS</label>
</div>
<div class="toggle-switch form-check">
<input type="checkbox" name="toggle-switch-input-2812" id="toggle-switch-2812" 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-2812">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="myInputField8989" class="form-label ">
Passwort
</label>
<input class="form-control" id="myInputField8989" type="password" aria-describedby="myInputField8989Help " placeholder="Geben Sie hier Ihr passwort ein" name="myInputField8989">
<small id="myInputField8989Help" 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="myInputField2580" class="form-label ">
Textfeld
</label>
<input class="form-control is-invalid" id="myInputField2580" type="text" aria-describedby="myInputField2580Invalid " name="myInputField2580">
<div class="message message--error" id="myInputField2580Invalid">
Bitte füllen Sie dieses Feld aus.
</div>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField3191" class="form-label ">
Textfeld
</label>
<input class="form-control is-valid" id="myInputField3191" type="text" aria-describedby="myInputField3191Valid " value="Ich bin ein Text" name="myInputField3191">
<div class="message message--success" id="myInputField3191Valid">
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="myCheckbox6024Invalid " id="myCheckbox6024" name="myCheckbox6024">
<label class="form-check-label" for="myCheckbox6024">Checkbox</label>
<div id="myCheckbox6024Invalid" 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="myCheckbox2768Valid " id="myCheckbox2768" name="myCheckbox2768">
<label class="form-check-label" for="myCheckbox2768">Checkbox</label>
<div id="myCheckbox2768Valid" 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="myInputField5086" class="form-label aural">
Textfeld
</label>
<input class="form-control" id="myInputField5086" type="text" name="myInputField5086">
</div>
<div class="form-group">
<label for="mySelect4627" class="form-label aural">
Auswahlliste
</label>
<select class="form-control" id="mySelect4627" name="mySelect4627">
<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="myCheckbox5195" name="myCheckbox5195">
<label class="form-check-label" for="myCheckbox5195">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="myInputField1085" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField1085" type="text" name="myInputField1085">
</div>
<div class="form-group">
<label for="myInputField9355" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField9355" type="text" name="myInputField9355">
</div>
<button type="submit" class="button">Button</button>
</div></form>