Skip to content

Input

Interactive specimen

Native controls work. Demo links and submissions stay inside this specimen.

Source markup
<!-- @dsCard group="Inputs" height=640 -->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Input</title>
<style>
  /* Preview layout only; the host supplies tokens.css and bundle.css. */
  .demo { display: grid; gap: var(--space-md); padding: var(--space-sm); }
  .demo__states {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(var(--space-3xl) * 3)), 1fr));
    gap: var(--space-md);
    align-items: start;
  }
  .demo__state { display: grid; gap: var(--space-2xs); min-width: 0; }
  /* Static copy of .input:focus-visible. Native keyboard focus also works. */
  .input.is-focus {
    outline: var(--focus-width) solid transparent;
    outline-offset: var(--focus-offset);
    border-color: var(--color-semantic-border-strong);
    box-shadow: var(--shadow-focus-ring);
  }
</style>
</head>
<body>
<main class="demo">
  <h1 class="t-h3">Input</h1>
  <p class="field__help">Static state examples. Editing works; validation and submission are not connected.</p>
  <div class="demo__states">
    <div class="demo__state">
      <p class="t-label">Rest</p>
      <div class="field">
        <label class="field__label" for="nz-alias">Alias (optional)</label>
        <input class="input" id="nz-alias" name="alias" type="text" placeholder="For example, nightjar" aria-describedby="nz-alias-help">
        <p class="field__help" id="nz-alias-help">Choose the handle to display beside your message.</p>
      </div>
    </div>
    <div class="demo__state">
      <p class="t-label">Valid example</p>
      <div class="field">
        <label class="field__label" for="nz-email-valid">Email</label>
        <input class="input input--valid" id="nz-email-valid" name="email-valid" type="email" value="signal@example.com" aria-describedby="nz-email-valid-help">
        <p class="field__success" id="nz-email-valid-help">Valid format example. Delivery has not been checked.</p>
      </div>
    </div>
    <div class="demo__state">
      <p class="t-label">Error</p>
      <div class="field">
        <label class="field__label" for="nz-email-bad">Email (required)</label>
        <input class="input input--error" id="nz-email-bad" name="email-bad" type="email" required value="signal@" aria-invalid="true" aria-describedby="nz-email-bad-help nz-email-bad-error">
        <p class="field__help" id="nz-email-bad-help">Include the part after the @ sign.</p>
        <p class="field__error" id="nz-email-bad-error">Enter a complete email address, such as signal@example.com.</p>
      </div>
    </div>
    <div class="demo__state">
      <p class="t-label">Focus visible</p>
      <div class="field">
        <label class="field__label" for="nz-alias-focus">Alias</label>
        <input class="input is-focus" id="nz-alias-focus" name="alias-focus" type="text" value="nightjar" aria-describedby="nz-alias-focus-help">
        <p class="field__help" id="nz-alias-focus-help">Tab to a field to inspect its keyboard focus ring.</p>
      </div>
    </div>
    <div class="demo__state">
      <p class="t-label">Disabled</p>
      <div class="field">
        <label class="field__label" for="nz-alias-disabled">Alias</label>
        <input class="input" id="nz-alias-disabled" name="alias-disabled" type="text" value="nightjar" disabled aria-describedby="nz-alias-disabled-help">
        <p class="field__help" id="nz-alias-disabled-help">Unavailable until an account is selected.</p>
      </div>
    </div>
    <div class="demo__state">
      <p class="t-label">Read-only</p>
      <div class="field">
        <label class="field__label" for="nz-reference">Reference</label>
        <input class="input" id="nz-reference" name="reference" type="text" value="DEMO-014" readonly aria-describedby="nz-reference-help">
        <p class="field__help" id="nz-reference-help">You can select and copy this reference; it cannot be edited here.</p>
      </div>
    </div>
  </div>
</main>
</body>
</html>

A native single-line field with a persistent visible label, supporting text, email, URL and number entry. Use Select for a fixed list of choices and Textarea for several lines.

Wrap the control in .field. Bind a visible .field__label with for and a unique input id. Supply name for form data and the appropriate native type, autocomplete and constraints for the context. Mark required fields in their label and with required. A placeholder offers an example; it never replaces the label.

Connect help and error IDs through aria-describedby, retaining both when an error appears. Write the correction in .field__error and set aria-invalid="true". The attribute styles the error border; .input--error remains available for existing consumers but must carry the attribute too. Keep the user’s value when reporting a problem.

  • Rest uses color-semantic-bg-raised, color-semantic-border-input and radius-sm.
  • Focus uses shadow-focus-ring with an outline at focus-width and focus-offset. Error and valid borders remain visible while focused.
  • .input--valid and .field__success use color-semantic-status-success. Apply them only after a relevant check, with explanatory text. An email format check does not prove delivery.
  • Error uses color-semantic-status-error with a written correction, never colour alone.
  • Native disabled uses color-semantic-text-faint on color-semantic-bg-secondary. It prevents editing, skips keyboard focus and excludes the value from form submission. Explain why beside the field.
  • Native readonly keeps text selectable, focusable and included in form data. It uses color-semantic-bg-secondary; label the state in help text.

Keep native roles and keyboard editing. Tab visits enabled fields, including read-only fields. The control retains the shared minimum height. Do not hide labels or depend on a tooltip for instructions. For errors added dynamically, the application must provide an appropriate announcement or focus strategy.

The preview is static HTML/CSS. It does not validate or submit, and editing does not update the pictured states. There is no form endpoint. Consumers provide validation, state updates and submission handling; native constraints are not a substitute for server validation.