Skip to content
Dalvan UI

Input

Style a native text input with optional icons and affixes.

Playground

<div class="dv-field">
  <label class="dv-field__label" for="playground-budget">Budget</label>
  <div class="dv-field__control dv-input">
    <input class="dv-input__control" id="playground-budget" inputmode="decimal" value="150" />
  </div>
</div>

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 attributeBehavior
dv-inputdv-input__controlWrapper and required direct input. Focus and disabled styling on the wrapper follow the input.
dv-input--smdv-input--mddv-input--lgSets type size and padding. Medium is the default.
dv-input__leadingdv-input__trailingOptional direct icon slots.
dv-input__prefixdv-input__suffixOptional direct text affixes.
disabledaria-invalid=trueUse 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.

PropertyEffect and defaults
--dv-input-padding-block / --dv-input-padding-inlineControl and wrapper spacing set by the selected size.
--dv-input-backgroundSurface color computed from the surrounding appearance.
--dv-color-muted-weightAmount of foreground retained in icons and affixes.
--dv-icon-sizeOverrides SVG dimensions in icon slots.