Skip to the content
Konstruktor UI

Actions and inputs

Select

A native <select> inside .kui-select, which draws our frame and the arrow. The list that opens is the browser’s own, so it works the same with a mouse, a keyboard, a phone and a screen reader.

CSS only

Examples

One value from a short list

HTML
<div class="kui-field">
  <label class="kui-label" for="select-country">Country of residence</label>
  <div class="kui-select">
    <select id="select-country" name="country" autocomplete="country-name">
      <option>Srbija</option>
      <option>Bosna i Hercegovina</option>
      <option>Crna Gora</option>
      <option>Hrvatska</option>
      <option>Deutschland</option>
      <option>Österreich</option>
      <option>Sverige</option>
    </select>
  </div>
</div>

Groups and a first empty option

<optgroup> names the groups. When no value is chosen yet, start with an empty option whose text says to choose, and make the select required.

HTML
<div class="kui-field">
  <label class="kui-label" for="select-policy">Insurance<span class="kui-required" aria-hidden="true">*</span></label>
  <div class="kui-select">
    <select id="select-policy" name="policy" required>
      <option value="">Choose a policy</option>
      <optgroup label="Vehicle">
        <option>Kraftfahrzeughaftpflichtversicherung</option>
        <option>Kasko, full cover</option>
      </optgroup>
      <optgroup label="Home">
        <option>Household contents</option>
        <option>Building and earthquake</option>
      </optgroup>
      <optgroup label="Travel">
        <option>Travel health, Europe</option>
        <option disabled>Travel health, worldwide (from January)</option>
      </optgroup>
    </select>
  </div>
</div>

Small, in a toolbar

Next to a table or a list, a select can sort or set the page size. Its label can sit beside it.

HTML
<div class="kui-cluster">
  <label class="kui-label" for="select-sort">Sort by</label>
  <div class="kui-select">
    <select id="select-sort">
      <option>Newest first</option>
      <option>Oldest first</option>
      <option>Amount, high to low</option>
      <option>Customer, A to Ž</option>
    </select>
  </div>
</div>

States

Every state

Hover darkens the outline; focus shows the ring. Disabled is the native attribute. An invalid select has a red outline and its message linked with aria-describedby.

Choose the city of the office.

HTML
<div class="kui-form kui-form--wide">
<div class="kui-form__row">
  <div class="kui-field"><label class="kui-label" for="select-s1">Default</label><div class="kui-select"><select id="select-s1"><option>Beograd</option><option>Novi Sad</option></select></div></div>
  <div class="kui-field"><label class="kui-label" for="select-s2">Disabled</label><div class="kui-select"><select id="select-s2" disabled><option>Beograd</option></select></div></div>
  <div class="kui-field"><label class="kui-label" for="select-s3">Invalid</label><div class="kui-select"><select id="select-s3" aria-invalid="true" aria-describedby="select-s3-e"><option value="">Choose a city</option><option>Niš</option></select></div><p class="kui-error-text" id="select-s3-e"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#circle-alert"></use></svg><span>Choose the city of the office.</span></p></div>
</div>
</div>

Classes and attributes

.kui-select
The frame around a native select, with the arrow drawn by the class.
.kui-select > select
The select itself; it needs no class of its own.
optgroup label
Names a group of options.
required + option value=""
A first empty option that the form refuses.
aria-invalid="true"
Marks the select invalid; link the message with aria-describedby.

Keyboard

Up or Down
Changes the value, or moves in the open list.
Alt + Down or Space
Opens the list.
A letter
Jumps to the first option that starts with it.
Enter or Escape
Takes the marked option or closes the list.

Accessibility

  • The native select is announced as a pop-up button with its value, and the list is the platform’s own.
  • A phone opens its own picker, which is easier to use than any list drawn in the page.
  • The arrow is drawn in CSS and is not read.
  • Every select has a visible label tied with for.

Do and do not

Do

  • Use it for 4 to about 15 options.
  • Put the options in an order a person expects: by use, alphabet or size.
  • Choose a sensible default when there is one.

Do not

  • Do not use it for two or three options; radios show them all at once.
  • Do not use it for long lists that need typing; use a combobox.
  • Do not change the page when the value changes, without a button.