Usage
After setting up the CSS, apply dv-form to a form element and group action buttons in dv-form__actions.
<form class="dv-form">
<div class="dv-field">
<label class="dv-field__label" for="form-project">Project</label>
<div class="dv-field__control dv-input">
<input class="dv-input__control" id="form-project" name="project" value="Dalvan" />
</div>
</div>
<div class="dv-field">
<label class="dv-field__label" for="form-owner">Owner</label>
<div class="dv-field__control dv-input">
<input class="dv-input__control" id="form-owner" name="owner" value="Design team" />
</div>
</div>
<div class="dv-form__actions">
<button class="dv-button dv-appearance-subtle dv-appearance-interactive" type="reset">Reset</button>
</div>
</form> Examples
Aligned labels and actions
Horizontal forms align the labels of direct field children in a shared column. Actions align with the controls. Edit either value and activate Reset to restore the initial values.
<form class="dv-form dv-form--horizontal">
<div class="dv-field">
<label class="dv-field__label" for="form-project">Project</label>
<div class="dv-field__control dv-input">
<input class="dv-input__control" id="form-project" name="project" value="Dalvan" />
</div>
</div>
<div class="dv-field">
<label class="dv-field__label" for="form-owner">Owner</label>
<div class="dv-field__control dv-input">
<input class="dv-input__control" id="form-owner" name="owner" value="Design team" />
</div>
</div>
<div class="dv-form__actions">
<button class="dv-button dv-appearance-subtle dv-appearance-interactive" type="reset">Reset</button>
</div>
</form> Wrapping inline form
Use an inline form for compact sets of controls. Fields and actions wrap when space runs out.
<form class="dv-form dv-form--inline">
<div class="dv-field">
<label class="dv-field__label" for="inline-project">Project</label>
<div class="dv-field__control dv-input">
<input class="dv-input__control" id="inline-project" name="project" value="Dalvan" />
</div>
</div>
<div class="dv-field">
<label class="dv-field__label" for="inline-owner">Owner</label>
<div class="dv-field__control dv-input">
<input class="dv-input__control" id="inline-owner" name="owner" value="Design team" />
</div>
</div>
<div class="dv-form__actions">
<button class="dv-button dv-appearance-subtle dv-appearance-interactive" type="reset">Reset</button>
</div>
</form> API reference
| Class or attribute | Behavior |
|---|---|
dv-form | Stacked grid with spacing between direct children. |
dv-form--horizontal | Aligns direct fields to the shared label and control columns. |
dv-form--inline | Places direct children in a wrapping flex row. |
dv-form__actions | Wrapping action row. Place it directly in a horizontal form to align it with the controls. |
type=submittype=resettype=button | Choose explicit native button behavior for each action. |
Customization
Use a gap utility such as dv-gap-100 on the form or action row to adjust spacing. Direct fields can override the inherited form layout at individual breakpoints.