Text fields are used for inputs that appear in forms, such as registration or changing the delivery address. The text area is used similarly to the text field and is used for longer text inputs, such as the review of a product.
Configurator
<oc-text-field-v1 hint="Bitte gib deinen Vornamen so an wie im Personalausweis.">Vorname</oc-text-field-v1>Usage
Anatomy
- Container
- Label
- Input
- Hint
- Counter
HTML
<div class="anatomy" style="display:block;max-width:360px;margin:28px auto">
<oc-text-field-v1 value="Lara" hint="Hinweis" maxlength="30">Vorname</oc-text-field-v1>
<span class="anatomy-pin" style="left:-16px;top:35%">1</span>
<span class="anatomy-pin" style="left:6%;top:-18px">2</span>
<span class="anatomy-pin" style="left:18%;top:38%">3</span>
<span class="anatomy-pin" style="left:-16px;top:92%">4</span>
<span class="anatomy-pin" style="left:calc(100% + 16px);top:92%">5</span>
<ol class="anatomy-key"><li data-n="1">Container</li><li data-n="2">Label</li><li data-n="3">Input</li><li data-n="4">Hint</li><li data-n="5">Counter</li></ol>Variants
Text fields have the following semantic variants:
- Default
- Error
- Success
- Warning
The error, success, or warning variants can occur after an input from the default state.
Default
Error
Success
Warning
HTML
<oc-text-field-v1 hint="Hinweis" maxlength="30">Vorname</oc-text-field-v1>
<oc-text-field-v1 hint="Hinweis" maxlength="30" variant="error">Vorname</oc-text-field-v1>
<oc-text-field-v1 hint="Hinweis" maxlength="30" variant="success">Vorname</oc-text-field-v1>
<oc-text-field-v1 hint="Hinweis" maxlength="30" variant="warning">Vorname</oc-text-field-v1>
Text area
In comparison to the text field, the text area is used for longer inputs. Per default, it has a height of three lines. With the property resizable, users can manually resize it using the native handle in the bottom right corner. Text areas have the same variants as text fields.
Text area
Resizable (drag the corner)
HTML
<p class="demo-label">Text area</p>
<oc-text-area-v1 hint="Hinweis" maxlength="500" value="Bitte beim Nachbarn im Erdgeschoss abgeben, falls ich nicht zu Hause bin.">Lieferhinweis</oc-text-area-v1>
<p class="demo-label">Resizable (drag the corner)</p>
<oc-text-area-v1 hint="Hinweis" maxlength="500" resizable value="Bitte beim Nachbarn im Erdgeschoss abgeben, falls ich nicht zu Hause bin.">Lieferhinweis</oc-text-area-v1>
Input types
text
tel
url
integer
decimal
HTML
<p class="demo-label">text</p>
<oc-text-field-v1 type="text" value="Lara" hint="Hinweis">Vorname</oc-text-field-v1>
<p class="demo-label">tel</p>
<oc-text-field-v1 type="tel" value="04012897096782" hint="Hinweis">Telefonnummer</oc-text-field-v1>
<p class="demo-label">email</p>
<oc-text-field-v1 type="email" value="name@provider.de" hint="Hinweis">E-Mail-Adresse</oc-text-field-v1>
<p class="demo-label">url</p>
<oc-text-field-v1 type="url" value="www.otto.de" hint="Hinweis">Website</oc-text-field-v1>
<p class="demo-label">integer</p>
<oc-text-field-v1 type="integer" value="1" hint="Hinweis">Anzahl</oc-text-field-v1>
<p class="demo-label">decimal</p>
<oc-text-field-v1 type="decimal" value="12.24" hint="Hinweis">Betrag</oc-text-field-v1>
Counter, hint, and error
Text fields can also include a counter which is used for counting the letters and setting minimum or maximum values.
Text Fields come with an optional Hint. The Hint helps the user filling out the text field correctly and provides further context.
The error is shown additionally above the hint if the user made a wrong input. It helps the user understanding the mistake and fixing the input.
Counter (max.)
Hint and counter (min.)
Hint
Error and hint
HTML
<p class="demo-label">Counter (max.)</p>
<oc-text-field-v1 maxlength="30" value="Mein neuer Lieblingssessel">Titel</oc-text-field-v1>
<p class="demo-label">Hint and counter (min.)</p>
<oc-text-field-v1 minlength="2" value="WildFlora" hint="So nennen wir dich bei der Kommunikation und während des Bestellprozesses.">Spitzname</oc-text-field-v1>
<p class="demo-label">Hint</p>
<oc-text-field-v1 value="Lara" hint="Bitte gib deinen Vornamen an, wie er im Personalausweis angegeben ist.">Vorname</oc-text-field-v1>
<p class="demo-label">Error and hint</p>
<oc-text-field-v1 value="12345" validation-message="Der eingegebene Text ist kein Name. Bitte korrigiere deine Eingabe." hint="Bitte gib deinen Vornamen an, wie er im Personalausweis angegeben ist.">Vorname</oc-text-field-v1>
Placeholder
You can use placeholders to nudge users, which inputs are expected. In comparison to hints, placeholders are very short and mostly example content is provided. It is only visible, when focused but hidden as soon as input is provided.
Click the field: the placeholder appears once it has focus
HTML
<p class="demo-label">Click the field: the placeholder appears once it has focus</p>
<oc-text-field-v1 type="email" placeholder="max.mustermann@abc.de">E-Mail-Adresse</oc-text-field-v1>
Pre- and suffix
The prefix and suffix of a text field are optional and can contain icons or text. The prefix is always placed at the left and the suffix on the right inside a text field. Pre- and suffixes are only shown in the focused or filled state.
Prefix and suffix icon
Suffix text
HTML
<p class="demo-label">Prefix and suffix icon</p>
<oc-text-field-v1 type="decimal" value="50" prefix-icon="money-banknotes" suffix-icon="euro">Wunschbetrag</oc-text-field-v1>
<p class="demo-label">Suffix text</p>
<oc-text-field-v1 type="decimal" value="50" suffix-text="€">Wunschbetrag</oc-text-field-v1>
Behavior
States
All semantic variants have the following states, as shown in the image.
Enabled (hover, focus, type)
Filled
Disabled
HTML
<p class="demo-label">Enabled (hover, focus, type)</p>
<oc-text-field-v1 hint="Hinweis">Vorname</oc-text-field-v1>
<p class="demo-label">Filled</p>
<oc-text-field-v1 value="Lara" hint="Hinweis">Vorname</oc-text-field-v1>
<p class="demo-label">Disabled</p>
<oc-text-field-v1 disabled hint="Hinweis">Vorname</oc-text-field-v1>
Placement
When placing multiple Text Fields next to each other, make sure there is a gap of 8px in-between horizontally and a gap of 24px vertically. Be aware the vertical distance is measured not from the label but from the text field itself.
Side by side, 8px gap
HTML
<p class="demo-label">Side by side, 8px gap</p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" oc-aria-label="Name">
<oc-text-field-v1>Vorname</oc-text-field-v1>
<oc-text-field-v1>Nachname</oc-text-field-v1>
</oc-form-group-v1>
Stacked, 24px gap
HTML
<p class="demo-label">Stacked, 24px gap</p>
<oc-form-group-v1 orientation="vertical" gap="var(--oc-base-dimension-24)" oc-aria-label="Adresse">
<oc-text-field-v1 hint="Hinweis">Straße</oc-text-field-v1>
<oc-text-field-v1 value="1">Hausnummer</oc-text-field-v1>
<oc-text-field-v1>Postleitzahl</oc-text-field-v1>
</oc-form-group-v1>
Best practices
Content Guidelines
Accessibility
Related components
Implementation
Live demo
Deine Bestellung vom 12.09.
Loungesessel „Lotta“, Bouclé
Wie gefällt dir dein Sessel?
Deine Bewertung hilft anderen bei der Entscheidung.
HTML
<div style="max-width:720px;margin:0 auto;display:grid;grid-template-columns:repeat(auto-fit,minmax(15rem,1fr));gap:32px;align-items:start">
<div style="display:grid;gap:12px">
<img src="/previews/imagery/samples/otto-product-still/product-armchair.webp" alt="Loungesessel mit Holzgestell" style="display:block;width:100%;aspect-ratio:1;object-fit:cover;border-radius:12px">
<p class="oc-copy-75 oc-text-color-secondary">Deine Bestellung vom 12.09.</p>
<p class="oc-copy-100"><b>Loungesessel „Lotta“, Bouclé</b></p>
<div style="display:grid;gap:20px">
<div style="display:grid;gap:4px">
<p class="oc-headline-100">Wie gefällt dir dein Sessel?</p>
<p class="oc-copy-100 oc-text-color-secondary">Deine Bewertung hilft anderen bei der Entscheidung.</p>
<oc-text-field-v1 value="Richtig gemütlich" maxlength="50">Titel deiner Bewertung</oc-text-field-v1>
<oc-text-area-v1 maxlength="1000" hint="Was gefällt dir, was könnte besser sein?" value="Der Bouclé-Stoff fühlt sich toll an, und die Farbe ist genau wie auf den Fotos. Der Aufbau hat keine zehn Minuten gedauert.">Deine Erfahrung</oc-text-area-v1>
<oc-text-field-v1 value="LaraL" hint="Wird öffentlich neben deiner Bewertung angezeigt." maxlength="20">Spitzname</oc-text-field-v1>
<oc-button-v1 variant="primary">Bewertung abschicken</oc-button-v1>