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="myInputField6043" 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="myInputField6043" type="text" aria-describedby="myInputField6043Help " name="myInputField6043">
<small id="myInputField6043Help" class="formgroup__help">Helptext</small>
</div>
<div class="form-group">
<label for="mySelect6482" 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="mySelect6482" aria-describedby="mySelect6482Help " name="mySelect6482">
<option value="">Bitte wählen</option>
<option value="option1">Option1</option>
<option value="option2">Option2</option>
</select>
<small id="mySelect6482Help" 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="myCheckbox184" name="myCheckbox184">
<label class="form-check-label" for="myCheckbox184">Antwort 1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="myCheckbox5078" name="myCheckbox5078">
<label class="form-check-label" for="myCheckbox5078">Antwort 2</label>
</div>
</fieldset>
<fieldset >
<legend >
Frage
</legend>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox6352" name="exampleRadios1">
<label class="form-check-label" for="myCheckbox6352">Ja</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox6936" name="exampleRadios1">
<label class="form-check-label" for="myCheckbox6936">Nein</label>
</div>
</fieldset>
<div class="form-actions">
<div class="form-actions__left">
<a href="#randomtarget4269" 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="myInputField2372" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField2372" type="text" name="myInputField2372">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="mySelect8960" class="form-label">
Select
</label>
<select class="form-control" id="mySelect8960" name="mySelect8960">
<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="mySelect5095" class="form-label">
Multiselect
</label>
<select class="form-control" multiple id="mySelect5095" name="mySelect5095">
<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="myTextarea9101" class="form-label ">
Textarea
</label>
<textarea class="form-control" id="myTextarea9101" rows="3" name="myTextarea9101"></textarea>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField305" class="form-label ">
Dateiupload
</label>
<input class="form-control" id="myInputField305" type="file" name="myInputField305">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField3221" class="form-label ">
Time
</label>
<input class="form-control" id="myInputField3221" type="time" name="myInputField3221">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField3634" class="form-label ">
Number
</label>
<input class="form-control" id="myInputField3634" type="number" name="myInputField3634">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField4062" class="form-label ">
Url
</label>
<input class="form-control" id="myInputField4062" type="url" name="myInputField4062">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField1394" class="form-label ">
Datepicker native (input[type=date])
</label>
<input class="form-control" id="myInputField1394" type="date" name="myInputField1394">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField3712" class="form-label ">
Datepicker with flatpickr.js (input.datepicker)
</label>
<input class="form-control datepicker" id="myInputField3712" type="text" name="myInputField3712">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField3124" class="form-label ">
Readonly
</label>
<input class="form-control" readonly id="myInputField3124" type="text" value="Dieser Text ist nicht zu ändern" name="myInputField3124">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField1266" 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="myInputField1266" type="text" name="myInputField1266">
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField6984" class="form-label ">
Input as plaintext
</label>
<input class="form-control-plaintext" readonly id="myInputField6984" type="text" value="Dieser Wert sieht aus wie Plaintext" name="myInputField6984">
</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="myCheckbox5238" name="myCheckbox5238">
<label class="form-check-label" for="myCheckbox5238">Checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="myCheckbox4179" name="myCheckbox4179">
<label class="form-check-label" for="myCheckbox4179">Checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" disabled id="myCheckbox7982" name="myCheckbox7982">
<label class="form-check-label" for="myCheckbox7982">Disabled checkbox label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="myCheckbox8126" name="myCheckbox8126">
<label class="form-check-label" for="myCheckbox8126">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="myCheckbox1965" name="myCheckbox1965">
<label class="form-check-label" for="myCheckbox1965">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="myCheckbox5670" name="exampleRadios">
<label class="form-check-label" for="myCheckbox5670">Radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" id="myCheckbox1839" name="exampleRadios">
<label class="form-check-label" for="myCheckbox1839">Radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" disabled id="myCheckbox4614" name="exampleRadios">
<label class="form-check-label" for="myCheckbox4614">Disabled radio label</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" id="myCheckbox7796" name="exampleRadios">
<label class="form-check-label" for="myCheckbox7796">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="myCheckbox9207" name="exampleRadios">
<label class="form-check-label" for="myCheckbox9207">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="myCheckbox4185" name="myCheckbox4185">
<label class="form-check-label" for="myCheckbox4185">Checkbox label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="myCheckbox4032" name="myCheckbox4032">
<label class="form-check-label" for="myCheckbox4032">Checkbox label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" disabled id="myCheckbox1055" name="myCheckbox1055">
<label class="form-check-label" for="myCheckbox1055">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="myCheckbox8795" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox8795">Radio button label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="myCheckbox724" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox724">Radio button label</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" disabled id="myCheckbox9215" name="exampleRadios2">
<label class="form-check-label" for="myCheckbox9215">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-6973" id="toggle-switch-6973" 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-6973">Receive Notifications</label>
</div>
<div class="toggle-switch form-check">
<input type="checkbox" name="toggle-switch-input-3964" id="toggle-switch-3964" 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-3964">Receive SMS</label>
</div>
<div class="toggle-switch form-check">
<input type="checkbox" name="toggle-switch-input-8029" id="toggle-switch-8029" 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-8029">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="myInputField6503" class="form-label ">
Passwort
</label>
<input class="form-control" id="myInputField6503" type="password" aria-describedby="myInputField6503Help " placeholder="Geben Sie hier Ihr passwort ein" name="myInputField6503">
<small id="myInputField6503Help" 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="myInputField3441" class="form-label ">
Textfeld
</label>
<input class="form-control is-invalid" id="myInputField3441" type="text" aria-describedby="myInputField3441Invalid " name="myInputField3441">
<div class="message message--error" id="myInputField3441Invalid">
Bitte füllen Sie dieses Feld aus.
</div>
</div>
</form>
<form class="form--base panel--heavy">
<div class="form-group">
<label for="myInputField2795" class="form-label ">
Textfeld
</label>
<input class="form-control is-valid" id="myInputField2795" type="text" aria-describedby="myInputField2795Valid " value="Ich bin ein Text" name="myInputField2795">
<div class="message message--success" id="myInputField2795Valid">
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="myCheckbox5575Invalid " id="myCheckbox5575" name="myCheckbox5575">
<label class="form-check-label" for="myCheckbox5575">Checkbox</label>
<div id="myCheckbox5575Invalid" 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="myCheckbox6716Valid " id="myCheckbox6716" name="myCheckbox6716">
<label class="form-check-label" for="myCheckbox6716">Checkbox</label>
<div id="myCheckbox6716Valid" 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="myInputField510" class="form-label aural">
Textfeld
</label>
<input class="form-control" id="myInputField510" type="text" name="myInputField510">
</div>
<div class="form-group">
<label for="mySelect1396" class="form-label aural">
Auswahlliste
</label>
<select class="form-control" id="mySelect1396" name="mySelect1396">
<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="myCheckbox7786" name="myCheckbox7786">
<label class="form-check-label" for="myCheckbox7786">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="myInputField1561" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField1561" type="text" name="myInputField1561">
</div>
<div class="form-group">
<label for="myInputField7592" class="form-label ">
Textfeld
</label>
<input class="form-control" id="myInputField7592" type="text" name="myInputField7592">
</div>
<button type="submit" class="button">Button</button>
</div></form>