Configurator
<oc-dropdown-v1 label="Land" empty-option hint="Wähle das Land aus, in dem du lebst."><option>Deutschland</option><option>Österreich</option><option>Schweiz</option><option>Frankreich</option><option>Niederlande</option></oc-dropdown-v1>Usage
Anatomy
- Container
- Label
- Selection
- Chevron
- Hint
HTML
<div class="anatomy" style="display:block;max-width:360px;margin:28px auto">
<oc-dropdown-v1 label="Anrede" value="Frau" hint="Für eine persönliche Ansprache."><option>Frau</option><option>Herr</option><option>Divers</option></oc-dropdown-v1>
<span class="anatomy-pin" style="left:-16px;top:35%">1</span>
<span class="anatomy-pin" style="left:7%;top:-18px">2</span>
<span class="anatomy-pin" style="left:22%;top:38%">3</span>
<span class="anatomy-pin" style="left:calc(100% + 16px);top:38%">4</span>
<span class="anatomy-pin" style="left:-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">Selection</li><li data-n="4">Chevron</li><li data-n="5">Hint</li></ol>Variants
There are two variants of the dropdown:
- Default
- Error: The error variant is not only visualized by the error color but also by an error icon, which is due to accessibility. Additionally, the error should be explained.
Default
Error
HTML
<p class="demo-label">Default</p>
<oc-dropdown-v1 label="Anrede" empty-option hint="Für eine persönliche Ansprache."><option>Frau</option><option>Herr</option><option>Divers</option></oc-dropdown-v1>
<p class="demo-label">Error</p>
<oc-dropdown-v1 label="Anrede" empty-option validation-message="Bitte wähle eine Anrede aus." hint="Für eine persönliche Ansprache."><option>Frau</option><option>Herr</option><option>Divers</option></oc-dropdown-v1>
Hint and error
The dropdown comes with an optional hint. The hint helps the user choosing the correct answer 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.
Hint
Error and hint
HTML
<p class="demo-label">Hint</p>
<oc-dropdown-v1 label="Land" empty-option hint="Wähle das Land aus, in dem du lebst."><option>Deutschland</option><option>Österreich</option><option>Schweiz</option></oc-dropdown-v1>
<p class="demo-label">Error and hint</p>
<oc-dropdown-v1 label="Land" empty-option validation-message="Bitte wähle ein Land aus, um fortzufahren." hint="Wähle das Land aus, in dem du lebst."><option>Deutschland</option><option>Österreich</option><option>Schweiz</option></oc-dropdown-v1>
Behavior
States
Empty (hover, focus it)
Filled
Disabled, empty
Disabled, filled
HTML
<p class="demo-label">Empty (hover, focus it)</p>
<oc-dropdown-v1 label="Anrede" empty-option hint="Hinweis"><option>Frau</option><option>Herr</option><option>Divers</option></oc-dropdown-v1>
<p class="demo-label">Filled</p>
<oc-dropdown-v1 label="Anrede" value="Frau" hint="Hinweis"><option>Frau</option><option>Herr</option><option>Divers</option></oc-dropdown-v1>
<p class="demo-label">Disabled, empty</p>
<oc-dropdown-v1 label="Anrede" empty-option disabled hint="Hinweis"><option>Frau</option><option>Herr</option><option>Divers</option></oc-dropdown-v1>
<p class="demo-label">Disabled, filled</p>
<oc-dropdown-v1 label="Anrede" value="Frau" disabled hint="Hinweis"><option>Frau</option><option>Herr</option><option>Divers</option></oc-dropdown-v1>
Interaction
When the user chooses an option the label will move to the top left and the selection will be displayed inside the container. Depending on the position of the dropdown, the dropdown can open upward or downward. The dropdown uses the native dropdown list of the operating system.
Tap inside the dropdown, then choose a selection
↓ after the selection
HTML
<oc-dropdown-v1 label="Versandart" empty-option hint="Hinweis"><option>Standardversand</option><option>Expressversand</option><option>Wunschtermin</option><option>Abholung im Paketshop</option><option>Abholung in der Filiale</option></oc-dropdown-v1>
<oc-dropdown-v1 label="Versandart" value="Expressversand" hint="Hinweis"><option>Standardversand</option><option>Expressversand</option><option>Wunschtermin</option><option>Abholung im Paketshop</option><option>Abholung in der Filiale</option></oc-dropdown-v1>
Fitting
The width of the dropdown is set to fill-parent by default. The dropdown's height uses fit-content and adapts when a hint or error is visible.
Fills the parent width, height fits the content
HTML
<p class="demo-label">Fills the parent width, height fits the content</p>
<oc-dropdown-v1 label="Anrede" empty-option hint="Hinweis"><option>Frau</option><option>Herr</option><option>Divers</option></oc-dropdown-v1>
Placement
You can place multiple dropdowns side by side. When placing them horizontally, make sure there is an 8px gap between them. Use a form group to set only one hint and error for horizontally placed dropdowns. Vertically, there should be a 24px gap.
Side by side in a form group, 8px gap
HTML
<p class="demo-label">Side by side in a form group, 8px gap</p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" hint="Hinweis" oc-aria-label="Lieferung">
<oc-dropdown-v1 label="Land" empty-option><option>Deutschland</option><option>Österreich</option></oc-dropdown-v1>
<oc-dropdown-v1 label="Versandart" empty-option><option>Standard</option><option>Express</option></oc-dropdown-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="Lieferung">
<oc-dropdown-v1 label="Land" empty-option hint="Hinweis"><option>Deutschland</option><option>Österreich</option></oc-dropdown-v1>
<oc-dropdown-v1 label="Versandart" empty-option hint="Hinweis"><option>Standard</option><option>Express</option></oc-dropdown-v1>
<oc-dropdown-v1 label="Zustellung" empty-option hint="Hinweis"><option>Bis zur Haustür</option><option>Bis in die Wohnung</option></oc-dropdown-v1>
</oc-form-group-v1>
You can group multiple related dropdowns horizontally, e.g. for choosing the date - though a text field with type date may be appropriate for this task too. Form group can be used to set a hint for all combined form elements.
HTML
<oc-form-group-v1 orientation="horizontal" flex-behavior="shrink" gap="var(--oc-base-dimension-8)" hint="Hinweis" oc-aria-label="Geburtstag" style="justify-content:center">
<oc-dropdown-v1 label="Tag" empty-option style="width:6rem"><option>1</option><option>2</option><option>3</option></oc-dropdown-v1>
<oc-dropdown-v1 label="Monat" empty-option style="width:10rem"><option>Januar</option><option>Februar</option><option>März</option></oc-dropdown-v1>
<oc-dropdown-v1 label="Jahr" empty-option style="width:7rem"><option>1990</option><option>1991</option><option>1992</option></oc-dropdown-v1>
</oc-form-group-v1>
Best practices
Content guidelines
Accessibility
Implementation
Live demo
Persönliche Daten
Damit wir dich richtig ansprechen und dir zum Geburtstag gratulieren können.
Geburtsdatum
HTML
<div style="max-width:480px;margin:0 auto;display:grid;gap:24px">
<div style="display:grid;gap:4px">
<p class="oc-headline-100">Persönliche Daten</p>
<p class="oc-copy-100 oc-text-color-secondary">Damit wir dich richtig ansprechen und dir zum Geburtstag gratulieren können.</p>
<oc-dropdown-v1 label="Anrede" value="Frau"><option>Frau</option><option>Herr</option><option>Divers</option><option>Keine Angabe</option></oc-dropdown-v1>
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" oc-aria-label="Name">
<oc-text-field-v1 value="Lara" autocomplete="given-name">Vorname</oc-text-field-v1>
<oc-text-field-v1 value="Lavendel" autocomplete="family-name">Nachname</oc-text-field-v1>
</oc-form-group-v1>
<div style="display:grid;gap:12px">
<p class="oc-copy-100"><b>Geburtsdatum</b></p>
<oc-form-group-v1 orientation="horizontal" flex-behavior="grow" gap="var(--oc-base-dimension-8)" hint="Optional. Wir verwenden es nur für deinen Geburtstagsgruß." oc-aria-label="Geburtsdatum">
<oc-dropdown-v1 label="Tag" value="14" style="flex:0 1 6rem"><option>12</option><option>13</option><option>14</option><option>15</option></oc-dropdown-v1>
<oc-dropdown-v1 label="Monat" value="Mai"><option>März</option><option>April</option><option>Mai</option><option>Juni</option></oc-dropdown-v1>
<oc-dropdown-v1 label="Jahr" value="1991" style="flex:0 1 7rem"><option>1990</option><option>1991</option><option>1992</option></oc-dropdown-v1>
</oc-form-group-v1>
<oc-button-v1 variant="primary">Speichern</oc-button-v1>