Usage
After setting up the CSS, put a native input with dv-input__control directly inside dv-input. Provide a visible label and connect it to the input’s id.
<label for="input-project">Project</label>
<div class="dv-input">
<input class="dv-input__control" id="input-project" name="project" />
</div> Examples
Icons, prefix and suffix
Leading and trailing slots support SVGs. Prefix and suffix are for visible affixes. Include meaningful units in the accessible label.
<label for="input-budget">Budget in US dollars</label>
<div class="dv-input dv-input--lg">
<span class="dv-input__leading"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
<path d="M5 12h14M12 5v14" />
</svg></span>
<span class="dv-input__prefix" aria-hidden="true">$</span>
<input class="dv-input__control" id="input-budget" inputmode="decimal" value="150" />
<span class="dv-input__suffix" aria-hidden="true">USD</span>
<span class="dv-input__trailing"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
<path d="M5 12h14M12 5v14" />
</svg></span>
</div> Disabled and invalid inputs
Set native disabled or aria-invalid on the input itself. Use a Field to associate an error message with an invalid input.
Use at least two characters.
<div class="dv-input dv-input--sm">
<input class="dv-input__control" aria-label="Archived project" value="Archived" disabled />
</div>
<div class="dv-field">
<label class="dv-field__label" for="input-code">Project code</label>
<div class="dv-field__control dv-input">
<input class="dv-input__control" id="input-code" value="a"
aria-invalid="true" aria-describedby="input-code-error" />
</div>
<p class="dv-field__error-text dv-color-danger dv-appearance-plain" id="input-code-error">
Use at least two characters.
</p>
</div> API reference
| Class or attribute | Behavior |
|---|---|
dv-inputdv-input__control | Wrapper and required direct input. Focus and disabled styling on the wrapper follow the input. |
dv-input--smdv-input--mddv-input--lg | Sets type size and padding. Medium is the default. |
dv-input__leadingdv-input__trailing | Optional direct icon slots. |
dv-input__prefixdv-input__suffix | Optional direct text affixes. |
disabledaria-invalid=true | Use native disabled and ARIA invalid state on the control. |
Customization
Adjust component tokens on the wrapper. The control and its slots use the resulting spacing.
| Property | Effect and defaults |
|---|---|
--dv-input-padding-block / --dv-input-padding-inline | Control and wrapper spacing set by the selected size. |
--dv-input-background | Surface color computed from the surrounding appearance. |
--dv-color-muted-weight | Amount of foreground retained in icons and affixes. |
--dv-icon-size | Overrides SVG dimensions in icon slots. |