Skip to main content
GOV UI Lightweight UI for government software.

Select

A labelled select for choosing one option from a short list.

When to use it

When not to use it

Examples

Each example is a conformance case: every emitter — React, and each framework adapter — is checked against exactly this markup.

basic

Rendered
HTML
<div class="gov-field">
  <label class="gov-field__label" for="department">Department</label>
  <select class="gov-select" id="department" name="department">
    <option value="all">All departments</option>
    <option value="engineering">Engineering</option>
    <option value="finance">Finance</option>
  </select>
</div>
{
  "name": "department",
  "label": "Department",
  "options": [
    {
      "value": "all",
      "label": "All departments"
    },
    {
      "value": "engineering",
      "label": "Engineering"
    },
    {
      "value": "finance",
      "label": "Finance"
    }
  ]
}

with-value

Rendered
HTML
<div class="gov-field">
  <label class="gov-field__label" for="department">Department</label>
  <select class="gov-select" id="department" name="department">
    <option value="all">All departments</option>
    <option value="engineering">Engineering</option>
    <option value="finance" selected>Finance</option>
  </select>
</div>
{
  "name": "department",
  "label": "Department",
  "value": "finance",
  "options": [
    {
      "value": "all",
      "label": "All departments"
    },
    {
      "value": "engineering",
      "label": "Engineering"
    },
    {
      "value": "finance",
      "label": "Finance"
    }
  ]
}

with-error

Rendered

Error: Select a status.

HTML
<div class="gov-field gov-field--error">
  <label class="gov-field__label" for="status">Status</label>
  <p class="gov-field__error" id="status-error">
    <span class="gov-visually-hidden">Error:</span> Select a status.</p>
    <select class="gov-select gov-select--error" id="status" name="status" aria-describedby="status-error" aria-invalid="true">
      <option value="">Choose a status</option>
      <option value="active">Active</option>
    </select>
  </div>
{
  "name": "status",
  "label": "Status",
  "error": "Select a status.",
  "options": [
    {
      "value": "",
      "label": "Choose a status"
    },
    {
      "value": "active",
      "label": "Active"
    }
  ]
}

Accessibility

Accessible name. The associated label.

Keyboard behavior
Key Behavior
TabMoves focus to the control.
Arrow keysMoves between options.
Type-aheadJumps to a matching option.

Class names

Class names
Role Class
wrapper.gov-field
wrapperInvalid.gov-field--error
label.gov-field__label
hint.gov-field__hint
error.gov-field__error
base.gov-select
invalid.gov-select--error

View the manifest for this component: packages/manifest/components/select.json