Usage
After setting up the CSS, place the label, control wrapper and any supporting text directly inside dv-field. Match the label’s for attribute to the control’s id.
<div class="dv-field">
<label class="dv-field__label" for="field-title">Project title</label>
<div class="dv-field__control">
<div class="dv-input">
<input class="dv-input__control" id="field-title" name="title" aria-describedby="field-title-hint" />
</div>
</div>
<p class="dv-field__helper-text" id="field-title-hint">Use a short, descriptive title.</p>
</div> Examples
Responsive label placement
The label stacks above the control on narrow screens and moves beside it from the md breakpoint. Helper text stays aligned with the control.
Use a short, descriptive title.
<div class="dv-field dv-field--vertical dv-md-field--horizontal">
<label class="dv-field__label" for="field-title">Project title</label>
<div class="dv-field__control">
<div class="dv-input">
<input class="dv-input__control" id="field-title" name="title" aria-describedby="field-title-hint" />
</div>
</div>
<p class="dv-field__helper-text" id="field-title-hint">Use a short, descriptive title.</p>
</div> Validation message
Set aria-invalid on the control when validation fails. Reference the visible error message in aria-describedby and use a descriptive message.
Enter an email address such as name@example.com.
<div class="dv-field">
<label class="dv-field__label" for="field-email">Email</label>
<div class="dv-field__control dv-input">
<input class="dv-input__control" type="email" id="field-email"
value="name" aria-invalid="true" aria-describedby="field-email-error" />
</div>
<p class="dv-field__error-text dv-color-danger dv-appearance-plain" id="field-email-error">
Enter an email address such as name@example.com.
</p>
</div> API reference
| Class or attribute | Behavior |
|---|---|
dv-field | Groups a single labeled control. Inherits the layout of its form and otherwise defaults to vertical. |
dv-field__labeldv-field__control | Direct label and control wrapper. |
dv-field__helper-textdv-field__error-text | Optional supporting text. Associate its id with the control. |
dv-field--verticaldv-field--horizontaldv-field--inline | Stack the parts, align label and control in columns, or fit them to their content. |
dv-{sm,md,lg,xl}-field--{vertical,horizontal,inline} | Apply a field layout beginning at the named breakpoint. |
Customization
Use spacing utilities for local changes and the form layout for consistent alignment across fields. Field labels and descriptions use shared typography tokens.