Skip to the content
Konstruktor UI

Actions and inputs

Checkbox and radio

Native <input type="checkbox"> and <input type="radio"> with .kui-checkbox and .kui-radio, inside a label.kui-check so the whole row is the target. A group of them sits in a fieldset.kui-fieldset with a legend.

<kui-check-all> needs kui.js; the markup works without it as described below

Examples

One checkbox, with a hint

.kui-check__text holds the label and a hint under it. The row is at least 44 pixels high on a phone.

HTML
<label class="kui-check">
  <input class="kui-checkbox" type="checkbox" name="newsletter" checked>
  <span class="kui-check__text">
    <span>Send me the monthly summary</span>
    <span class="kui-hint">One email on the first working day of the month. You can stop it at any time.</span>
  </span>
</label>

A group with a legend

The legend names the question; each checkbox answers it. A hint under the legend is read with the group.

Notify me about

Choose all that apply.

HTML
<fieldset class="kui-fieldset" aria-describedby="checkbox-notify-hint">
  <legend>Notify me about</legend>
  <p class="kui-hint" id="checkbox-notify-hint">Choose all that apply.</p>
  <div class="kui-choices">
    <label class="kui-check"><input class="kui-checkbox" type="checkbox" name="notify" value="invoice" checked><span>A paid invoice</span></label>
    <label class="kui-check"><input class="kui-checkbox" type="checkbox" name="notify" value="deadline" checked><span>A deadline within three days</span></label>
    <label class="kui-check"><input class="kui-checkbox" type="checkbox" name="notify" value="comment"><span>A comment that mentions me</span></label>
    <label class="kui-check"><input class="kui-checkbox" type="checkbox" name="notify" value="law"><span>Changes to the Zakon o zaštiti podataka o ličnosti</span></label>
  </div>
</fieldset>

Select all, with the mixed state

In <kui-check-all> the checkbox with data-check-all checks or clears the others. When only some are checked it shows a dash: the indeterminate state, read as “mixed”. Uncheck one of the rooms to see it.

Rooms to clean
HTML
<kui-check-all>
  <fieldset class="kui-fieldset">
    <legend>Rooms to clean</legend>
    <div class="kui-choices">
      <label class="kui-check"><input class="kui-checkbox" type="checkbox" data-check-all><span>All rooms</span></label>
      <div class="kui-choices kui-choices--nested">
        <label class="kui-check"><input class="kui-checkbox" type="checkbox" name="room" value="kitchen" checked><span>Kitchen</span></label>
        <label class="kui-check"><input class="kui-checkbox" type="checkbox" name="room" value="bath" checked><span>Bathroom</span></label>
        <label class="kui-check"><input class="kui-checkbox" type="checkbox" name="room" value="bed"><span>Bedroom</span></label>
      </div>
    </div>
  </fieldset>
</kui-check-all>

Radios: one of a few

Radios with the same name are one group; the arrows move between them. Add .kui-choices--row to lay short ones in a row.

Delivery
Invoice in
HTML
<fieldset class="kui-fieldset">
  <legend>Delivery</legend>
  <div class="kui-choices">
    <label class="kui-check"><input class="kui-radio" type="radio" name="checkbox-delivery" value="post" checked><span class="kui-check__text"><span>Pošta Srbije</span><span class="kui-hint">3 to 5 working days, free</span></span></label>
    <label class="kui-check"><input class="kui-radio" type="radio" name="checkbox-delivery" value="courier"><span class="kui-check__text"><span>Courier</span><span class="kui-hint">Next working day, 450 RSD</span></span></label>
    <label class="kui-check"><input class="kui-radio" type="radio" name="checkbox-delivery" value="pickup"><span class="kui-check__text"><span>Pick up at the office in Čačak</span><span class="kui-hint">From tomorrow, 9:00 to 17:00</span></span></label>
  </div>
</fieldset>
<fieldset class="kui-fieldset">
  <legend>Invoice in</legend>
  <div class="kui-choices kui-choices--row">
    <label class="kui-check"><input class="kui-radio" type="radio" name="checkbox-cur" value="rsd" checked><span>RSD</span></label>
    <label class="kui-check"><input class="kui-radio" type="radio" name="checkbox-cur" value="eur"><span>EUR</span></label>
    <label class="kui-check"><input class="kui-radio" type="radio" name="checkbox-cur" value="chf"><span>CHF</span></label>
  </div>
</fieldset>

States

Every state

Hover darkens the box. Focus shows the ring around the box. Checked and indeterminate fill the box with the text colour. Disabled fades the whole row. Invalid gives the box a red outline, with the message under the group.

Accept the terms to continue.

HTML
<div class="kui-choices">
  <label class="kui-check"><input class="kui-checkbox" type="checkbox"><span>Not checked</span></label>
  <label class="kui-check"><input class="kui-checkbox" type="checkbox" checked><span>Checked</span></label>
  <label class="kui-check"><input class="kui-checkbox" type="checkbox" disabled><span>Disabled</span></label>
  <label class="kui-check"><input class="kui-checkbox" type="checkbox" checked disabled><span>Checked and disabled</span></label>
  <label class="kui-check"><input class="kui-radio" type="radio" name="checkbox-s" checked><span>Radio, chosen</span></label>
  <label class="kui-check"><input class="kui-radio" type="radio" name="checkbox-s"><span>Radio, not chosen</span></label>
  <label class="kui-check"><input class="kui-radio" type="radio" name="checkbox-s2" disabled><span>Radio, disabled</span></label>
</div>
<div class="kui-field">
  <label class="kui-check"><input class="kui-checkbox" type="checkbox" required aria-invalid="true" aria-describedby="checkbox-s-e"><span>I accept the terms of the Rahmenvereinbarung</span></label>
  <p class="kui-error-text" id="checkbox-s-e"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#circle-alert"></use></svg><span>Accept the terms to continue.</span></p>
</div>

Classes and attributes

label.kui-check
The row: the control and its text. The whole row takes the press.
.kui-checkbox, .kui-radio
On the native input. Draws the box, the tick, the dash and the dot.
.kui-check__text
A label with a hint under it.
fieldset.kui-fieldset > legend
A group and its name. A .kui-hint right after the legend is its hint.
.kui-choices, --row, --nested
The column of choices; --row lays them in a wrapping row; --nested indents choices that belong to the one above.
kui-check-all, data-check-all
The checkbox for the whole group, with the mixed state when some are checked.
aria-invalid="true"
Red outline on the box; put the message under the group.

Keyboard

Space
Checks or clears a checkbox; chooses the focused radio.
Tab
Moves to each checkbox, and to the chosen radio of a group.
Up or Down or Left or Right
Moves to the next radio of the group and chooses it.

Accessibility

  • They stay native inputs, so their role, state and group are announced without ARIA.
  • The indeterminate state is the input’s indeterminate property, read as “mixed”; it cannot be set from HTML, which is why kui-check-all sets it.
  • The legend is read before the first control of a group.
  • In forced-colours mode the boxes are drawn by the system.

Do and do not

Do

  • Write each label as a statement that is true when checked.
  • Use radios for two to six options that are all worth seeing.
  • Choose a default radio when one is safe; otherwise leave none chosen and make the group required.

Do not

  • Do not use a checkbox for an action that happens at once; use a switch.
  • Do not use a single radio; it cannot be cleared.
  • Do not put a link inside the label row; put it in the hint or next to it.