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="myInputField9159" 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="myInputField9159" type="text" aria-describedby="myInputField9159Help " name="myInputField9159">
<small id="myInputField9159Help" class="formgroup__help">Helptext</small>
</div>
<div class="form-group">
<label for="mySelect3068" 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="mySelect3068" aria-describedby="mySelect3068Help " name="mySelect3068">
<option value="">Bitte wählen</option>
<option value="option1">Option1</option>
<option value="option2">Option2</option>
</select>
<small id="mySelect3068Help" 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="myCheckbox5348" name="myCheckbox5348">
<label class="form-check-label" for="myCheckbox5348">Antwort 1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="myCheckbox5547" name="myCheckbox5547">
<label class="form-check-label" for="myCheckbox5547">Antwort 2</label>
</div>
</fieldset>
<fieldset >
<legend >
Frage
</legend>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox1301" name="exampleRadios1">
<label class="form-check-label" for="myCheckbox1301">Ja</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox5823" name="exampleRadios1">
<label class="form-check-label" for="myCheckbox5823">Nein</label>
</div>
</fieldset>
<div class="form-actions">
<div class="form-actions__left">
<a href="#randomtarget8166" 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="myInputField4783" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField4783" type="text" name="myInputField4783">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="mySelect1547" class="form-label">
Select
</label>
<select class="form-control" id="mySelect1547" name="mySelect1547">
<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="mySelect2998" class="form-label">
Multiselect
</label>
<select class="form-control" multiple id="mySelect2998" name="mySelect2998">
<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="myTextarea6878" class="form-label ">
Textarea
</label>
<textarea class="form-control" id="myTextarea6878" rows="3" name="myTextarea6878"></textarea>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField5236" class="form-label ">
Dateiupload
</label>
<input class="form-control" id="myInputField5236" type="file" name="myInputField5236">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField605" class="form-label ">
Time
</label>
<input class="form-control" id="myInputField605" type="time" name="myInputField605">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField6462" class="form-label ">
Number
</label>
<input class="form-control" id="myInputField6462" type="number" name="myInputField6462">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField7906" class="form-label ">
Url
</label>
<input class="form-control" id="myInputField7906" type="url" name="myInputField7906">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField2453" class="form-label ">
Datepicker native (input[type=date])
</label>
<input class="form-control" id="myInputField2453" type="date" name="myInputField2453">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField2169" class="form-label ">
Datepicker with flatpickr.js (input.datepicker)
</label>
<input class="form-control datepicker" id="myInputField2169" type="text" name="myInputField2169">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField5796" class="form-label ">
Readonly
</label>
<input class="form-control" readonly id="myInputField5796" type="text" value="Dieser Text ist nicht zu ändern" name="myInputField5796">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField6458" 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="myInputField6458" type="text" name="myInputField6458">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField2050" class="form-label ">
Input as plaintext
</label>
<input class="form-control-plaintext" readonly id="myInputField2050" type="text" value="Dieser Wert sieht aus wie Plaintext" name="myInputField2050">
</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="myCheckbox2221" name="myCheckbox2221">
<label class="form-check-label" for="myCheckbox2221">Checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="myCheckbox1036" name="myCheckbox1036">
<label class="form-check-label" for="myCheckbox1036">Checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" disabled id="myCheckbox7362" name="myCheckbox7362">
<label class="form-check-label" for="myCheckbox7362">Disabled checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="myCheckbox7221" name="myCheckbox7221">
<label class="form-check-label" for="myCheckbox7221">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="myCheckbox3679" name="myCheckbox3679">
<label class="form-check-label" for="myCheckbox3679">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="myCheckbox332" name="exampleRadios">
<label class="form-check-label" for="myCheckbox332">Radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" id="myCheckbox8969" name="exampleRadios">
<label class="form-check-label" for="myCheckbox8969">Radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" disabled id="myCheckbox9454" name="exampleRadios">
<label class="form-check-label" for="myCheckbox9454">Disabled radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" id="myCheckbox2696" name="exampleRadios">
<label class="form-check-label" for="myCheckbox2696">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="myCheckbox2399" name="exampleRadios">
<label class="form-check-label" for="myCheckbox2399">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="myCheckbox2398" name="myCheckbox2398">
<label class="form-check-label" for="myCheckbox2398">Checkbox label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="myCheckbox2050" name="myCheckbox2050">
<label class="form-check-label" for="myCheckbox2050">Checkbox label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" disabled id="myCheckbox5144" name="myCheckbox5144">
<label class="form-check-label" for="myCheckbox5144">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="myCheckbox1883" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox1883">Radio button label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox9241" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox9241">Radio button label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" disabled id="myCheckbox1636" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox1636">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-3915" id="toggle-switch-3915" 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-3915">Receive Notifications</label>
</div>
<div class="toggle-switch form-check">
<input type="checkbox" name="toggle-switch-input-2786" id="toggle-switch-2786" 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-2786">Receive SMS</label>
</div>
<div class="toggle-switch form-check">
<input type="checkbox" name="toggle-switch-input-6576" id="toggle-switch-6576" 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-6576">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="myInputField5381" class="form-label ">
Passwort
</label>
<input class="form-control" id="myInputField5381" type="password" aria-describedby="myInputField5381Help " placeholder="Geben Sie hier Ihr passwort ein" name="myInputField5381">
<small id="myInputField5381Help" 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="myInputField2090" class="form-label ">
Textfeld
</label>
<input class="form-control is-invalid" id="myInputField2090" type="text" aria-describedby="myInputField2090Invalid " name="myInputField2090">
<div class="message message--error" id="myInputField2090Invalid">
Bitte füllen Sie dieses Feld aus.
</div>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField3644" class="form-label ">
Textfeld
</label>
<input class="form-control is-valid" id="myInputField3644" type="text" aria-describedby="myInputField3644Valid " value="Ich bin ein Text" name="myInputField3644">
<div class="message message--success" id="myInputField3644Valid">
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="myCheckbox7266Invalid " id="myCheckbox7266" name="myCheckbox7266">
<label class="form-check-label" for="myCheckbox7266">Checkbox</label>
<div id="myCheckbox7266Invalid" 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="myCheckbox2488Valid " id="myCheckbox2488" name="myCheckbox2488">
<label class="form-check-label" for="myCheckbox2488">Checkbox</label>
<div id="myCheckbox2488Valid" 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="myInputField8098" class="form-label aural">
Textfeld
</label>
<input class="form-control" id="myInputField8098" type="text" name="myInputField8098">
</div>
<div class="form-group">
<label for="mySelect4787" class="form-label aural">
Auswahlliste
</label>
<select class="form-control" id="mySelect4787" name="mySelect4787">
<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="myCheckbox3131" name="myCheckbox3131">
<label class="form-check-label" for="myCheckbox3131">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="myInputField6595" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField6595" type="text" name="myInputField6595">
</div>
<div class="form-group">
<label for="myInputField4929" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField4929" type="text" name="myInputField4929">
</div>
<button type="submit" class="button">Button</button>
</div></form>