Skip to content

Select

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>Select</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">Select</h1>
  <p class="field__help">Static state examples. Choices work; 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-service">Service (required)</label>
        <select class="input input--select" id="nz-service" name="nz-service" required aria-describedby="nz-service-help">
          <option value="" selected>Choose a service</option>
          <option value="hosting">Hosting</option>
          <option value="cybersecurity">Cybersecurity</option>
          <option value="software">Software</option>
          <option value="support">Support</option>
        </select>
        <p class="field__help" id="nz-service-help">Choose the subject of your enquiry.</p>
      </div>
    </div>
    <div class="demo__state">
      <p class="t-label">Valid example</p>
      <div class="field">
        <label class="field__label" for="nz-service-valid">Service</label>
        <select class="input input--select input--valid" id="nz-service-valid" name="nz-service-valid" aria-describedby="nz-service-valid-help">
          <option value="hosting">Hosting</option>
          <option value="cybersecurity" selected>Cybersecurity</option>
          <option value="software">Software</option>
          <option value="support">Support</option>
        </select>
        <p class="field__success" id="nz-service-valid-help">Valid selection example: one service chosen.</p>
      </div>
    </div>
    <div class="demo__state">
      <p class="t-label">Error</p>
      <div class="field">
        <label class="field__label" for="nz-service-bad">Service (required)</label>
        <select class="input input--select input--error" id="nz-service-bad" name="nz-service-bad" required aria-invalid="true" aria-describedby="nz-service-bad-help nz-service-bad-error">
          <option value="" selected>Choose a service</option>
          <option value="hosting">Hosting</option>
          <option value="cybersecurity">Cybersecurity</option>
          <option value="software">Software</option>
          <option value="support">Support</option>
        </select>
        <p class="field__help" id="nz-service-bad-help">Choose the subject of your enquiry.</p>
        <p class="field__error" id="nz-service-bad-error">Choose a service from the list.</p>
      </div>
    </div>
    <div class="demo__state">
      <p class="t-label">Focus visible</p>
      <div class="field">
        <label class="field__label" for="nz-service-focus">Service</label>
        <select class="input input--select is-focus" id="nz-service-focus" name="nz-service-focus" aria-describedby="nz-service-focus-help">
          <option value="hosting">Hosting</option>
          <option value="cybersecurity">Cybersecurity</option>
          <option value="software" selected>Software</option>
          <option value="support">Support</option>
        </select>
        <p class="field__help" id="nz-service-focus-help">Use the platform's native keyboard controls to choose an option.</p>
      </div>
    </div>
    <div class="demo__state">
      <p class="t-label">Disabled</p>
      <div class="field">
        <label class="field__label" for="nz-service-disabled">Service</label>
        <select class="input input--select" id="nz-service-disabled" name="nz-service-disabled" disabled aria-describedby="nz-service-disabled-help">
          <option value="" selected>Choose an account first</option>
          <option value="hosting">Hosting</option>
          <option value="cybersecurity">Cybersecurity</option>
          <option value="software">Software</option>
          <option value="support">Support</option>
        </select>
        <p class="field__help" id="nz-service-disabled-help">Unavailable until an account is selected.</p>
      </div>
    </div>
    <div class="demo__state">
      <p class="t-label">Read-only alternative</p>
      <dl class="field">
        <dt class="field__label">Service</dt>
        <dd>Hosting</dd>
      </dl>
      <p class="field__help">A fixed choice is labelled text. Native select has no read-only state.</p>
    </div>
  </div>
</main>
</body>
</html>

A native single-choice menu for a short, known list. It reuses .input with .input--select, including the platform arrow and option popup. Use Input for free text and Textarea for several lines. This component is not a custom combobox or searchable menu.

Place <select class="input input--select"> inside .field, with a persistent visible .field__label whose for matches the select’s unique id. Supply name, meaningful option values and concise option labels. Bind help through aria-describedby. Use required and a visibly marked label when a choice is necessary; an initial option with value="" prompts for that choice.

Rest, focus, valid, error and disabled share Input’s rules. The surface uses color-semantic-bg-raised, the border uses color-semantic-border-input, and keyboard focus adds shadow-focus-ring. The native popup’s rendering varies by browser and operating system.

Use .input--valid with .field__success only after checking the selection. On error, set aria-invalid="true", retain help IDs and add the .field__error ID to aria-describedby. .input--error is an optional compatible class. Written feedback accompanies color-semantic-status-error, whose border remains visible during focus.

Native disabled prevents selection and keyboard focus, excludes the value from form submission and applies muted disabled styling. Keep the reason visible.

Select has no native readonly attribute. Present a fixed selection as labelled text, as the preview’s definition list demonstrates. If submission needs that value, the consumer must include it separately. Do not fake read-only behaviour with aria-readonly, blocked keys or pointer events.

Keep native semantics: no added role, tabindex or scripted key handling. Tab reaches an enabled select; the platform handles arrow navigation, typing to find options, opening and closing the list. The control retains the shared minimum height and keyboard focus indicator. Test the consuming form on its supported platforms.

The HTML/CSS preview is static. Selection works, but it does not validate or submit, and feedback does not update when a choice changes. Consumers own validation, error announcements and submission.