Skip to the page
Tactile UI

Kit part · Empty states

Result

The end of a task as one plate: a lens sunk into it with one lamp lit, a verdict, one sentence and what to do next. Green when it worked, amber when it worked with something to check, red when it did not. The verdict is a sentence that says which, so the lamp is only a second sign. When a result appears, focus moves to its verdict, so a keyboard user is where the news is and a screen reader says it.

Element
<section class="tui-result" role="status">
Needs
kit.css + kit.mjs
Covers
Result · Task complete
Rules
result.rules.md · 6
Finishes
Aluminium · Graphite · Oak · Walnut · Porcelain · Black · Daylight · Night · Paper · Phosphor · E-paper · AMOLED
Volumes
Tactile · Quiet
On this page
  1. Variants
  2. Every state, at once
  3. API
  4. Markup
  5. Accessibility
  6. How it’s built
  7. Rules
  8. Related parts

Seats open in 11 days. Want one email that morning?

Variants

Payment received

Your receipt is on its way to your inbox.

Success · green lamp

Imported, with 3 rows skipped

The other 212 customers are in. The skipped rows have no email address.

Warning · amber lamp
Failure · red lamp, role="alert"

Payment received

Your receipt is on its way to your inbox.

Order 1042 · 6 October, 14:02

With small print

Payment received

Your receipt is on its way to your inbox.

One key only

Imported, with 3 rows skipped

The other 212 customers are in. The skipped rows have no email address.

Beside the words · .tui-result--row

Every state, at once

Both finishes, side by side. Hover, pressed and focus are forced with .is-hover, .is-down and .is-focus; checked and disabled are real.

Aluminium

PartSuccessWarningFailureVerdict focused
Plate

All saved

One sentence.

Saved, with 3 skipped

One sentence.

All saved

One sentence.

Graphite

PartSuccessWarningFailureVerdict focused
Plate

All saved

One sentence.

Saved, with 3 skipped

One sentence.

All saved

One sentence.

API

NameKindValuesWhat it does
section.tui-result[data-result][role][aria-labelledby]elementsuccess · warning · failureThe plate. role="status" for success and warning, role="alert" for failure, named by its verdict.
.tui-result__lens > .tui-lamp[data-on]elementgreen · amber · redThe lens: a round bezel sunk into the plate with one lamp lit in it, hidden from a screen reader. data-lamp is amber or red; green needs none.
h2.tui-result__title[tabindex="-1"]elementthe verdictOne short sentence that says how it went (“Payment received”). Focus lands here, so tabindex="-1" is in the markup.
.tui-result__textclasson <p>One sentence: what it means and what was or was not changed.
.tui-result__detailclassoptional, on <p>Small print: an order number, a time.
.tui-result__nextclassthe keysWhat to do next: one key that matters (the contrast key), and perhaps one flat key.
--rowmodifiertui-result--rowThe lens beside the words, for a wide and short place; it folds back to a column on a phone.
data-no-focusattributeon the plateStops the plate taking the focus when it appears, for a result shown for reference.
showResult(result)functionneeds kit.mjsUnhides the plate and focuses its verdict.
focusResult(result)functionneeds kit.mjsFocuses the verdict.
resultRole(kind) · resultLamp(kind)functionpureThe ARIA role and the lamp colour for a kind.

Markup

<!-- success and warning are role="status"; a failure is role="alert". -->
<section class="tui-result" data-result="success" role="status" aria-labelledby="done">
  <div class="tui-result__lens"><span class="tui-lamp" data-on aria-hidden="true"></span></div>
  <h2 class="tui-result__title" id="done" tabindex="-1">Payment received</h2>
  <p class="tui-result__text">Your receipt is on its way to your inbox.</p>
  <div class="tui-result__next">
    <a class="tui-key tui-key--primary" href="/orders/1042">View the order</a>
    <a class="tui-key tui-key--flat" href="/shop">Back to shop</a>
  </div>
</section>

<!-- Amber: data-lamp="amber" with data-result="warning". Red: data-lamp="red" with data-result="failure" and role="alert". -->
import { showResult } from '/kit/kit.mjs';

// A result added to the page, or one that loses its hidden attribute, takes the focus on its own.
host.append(resultElement);

// Or say so yourself:
showResult(document.querySelector('.tui-result'));   // unhides it, focuses the verdict

Needs kit.css and kit.mjs. How to install the kit.

Accessibility

  • Focus moves to the verdict when a result appears: one that is added to the page after it has loaded, or that loses its hidden. The verdict has tabindex="-1", so it takes focus from a script but is not a stop of its own, and a screen reader says it at once.
  • Success and warning are role="status", read politely. A failure is role="alert", because the person has to know. The plate is named by its verdict with aria-labelledby.
  • The verdict says how it went in words (“Imported, with 3 rows skipped”), never “Done” alone. The lamp is hidden from a screen reader and the amber and red lamps are never the only sign.
  • The next step is a real key in the reading order straight after the sentence, so Tab from the verdict reaches it. The contrast key is the one that matters; the other key is flat.
  • Nothing moves; the lamp does not blink. Keys are 44px on a phone, the plate is as wide as its container and never scrolls sideways, and the verdict’s focus ring is 2px.

How it’s built

The raised plate and bead-blast of a panel, with the recess the kit uses for a well cut into it as a round bezel, and the kit’s lamp enlarged to sit in the middle of it, so every finish draws the lamp as it draws any lamp. The words are the empty state’s: a lead-sized bold title and a sentence in the secondary ink, balanced so they never leave a single word on a line. The focus rule is a small observer in result.mjs that waits for the page to finish loading, then focuses the verdict of any plate that arrives or is unhidden.

Rules

result.rules.mdIn the brain

Finish a task with a verdict, one sentence and the one thing to do next, and put the focus where the news is.

6 rules in this file, with the foundations they rest on and the anti-patterns that break them. Full rules ship in the brain with the Pass.

No circuits yet

Empty state

What a view shows before it has anything: an empty tray with the outline of what goes in it printed on its floor, one sentence and one key.

Check

Disk 82% full.

Alert

A message let into the surface, with an annunciator: a small lit legend (Note, Done, Check, Fault) beside the words that say what happened.

Key

Every button, and every link that acts like one: a cap on a skirt that drops below the plate when pressed.