UI States
Defining all component states before writing markup or JavaScript is a non-negotiable prerequisite for accessible and bug-free UI delivery.
An undocumented state becomes an unspecified behaviour at implementation time, which in turn becomes either a missing visual feedback path or an untested edge case in production.
Why Define States Early
| Without State Definition | With State Definition |
|---|---|
| Developers invent hover/focus styles ad hoc | Exact colours, cursors, and animations are specified |
| Empty and error states are shipped as blank areas | Placeholder copy and recovery guidance are reviewed before build |
| Loading is handled by a spinner thrown in at the last minute | Skeleton screens or progress patterns are deliberately chosen |
Accessibility reviewers find missing aria-* states post-launch | Required ARIA state attributes are part of the acceptance criteria |
Mandatory States for Every Interactive Component
The following states MUST be documented for every component that ships in a design system or project.
Interaction States
| State | Trigger | What to Specify |
|---|---|---|
| Default | No interaction | Background, border, text colour, cursor |
| Hover | Pointer over element | Visual change that does not rely on colour alone; cursor: pointer for links/buttons |
| Focus | Keyboard focus | outline or equivalent focus ring; visible (WCAG 2.4.7), with at least 3:1 contrast against adjacent colors (WCAG 1.4.11) |
| Active / Pressed | Mouse/touch down | Distinct feedback from hover; scale or background shift |
| Disabled | Functionally unavailable | cursor: not-allowed or cursor: default; a look that reads as disabled (color where possible, sometimes reduced opacity); no focus ring for disabled attribute |
Data / Content States
| State | Description | What to Specify |
|---|---|---|
| Empty | No data to display | Illustration or icon, heading, helper copy, and a primary action to break the empty state |
| Loading | Async data pending | Skeleton screen (preferred) or progress indicator; duration threshold for showing it |
| Partial / Populated | Some but not all data present | Pagination or progressive-disclosure pattern |
| Full / Limit Reached | Maximum capacity | Inline message explaining the limit and any remediation path |
| Error / Failed | Operation or data fetch failed | Error icon, plain-language message, and recovery action (retry / contact support) |
| Success / Completed | Operation succeeded | Confirmation copy; auto-dismiss timing if using a toast |
Form-Specific States
| State | Element | What to Specify |
|---|---|---|
| Placeholder | <input>, <textarea> | Hint text colour (MUST pass 4.5:1 contrast on the input background); never substitute for <label> |
| Typing / Active | <input>, <textarea> | Focus ring; real-time character count if a limit applies |
| Filled / Has Value | <input>, <select> | Distinct appearance so users know data was captured |
| Invalid | Any form control | Red border alone is insufficient; inline error message below the field linked via aria-describedby |
| Valid | Any form control | Optional green indicator only after initial submission attempt; avoid premature validation |
| Required | Any form control | Asterisk * with a legend; required attribute on the element |
| Read-only | <input readonly> | Visual difference from editable; readonly attribute so value is submitted but cannot be modified |
Rules Before the Design Handoff
Meet these rules before handing a design over to engineering.
- Define five interaction states for every interactive component MUSTUI-R08
- Draw default, hover, focus (with a visible focus indicator), pressed and disabled as variants. For disabled, also specify the cursor (
not-allowedordefault). Developers do not have to invent undefined states on the spot. - Check:
UI-02UI-02Five interaction states✕ NGFocus and 2 more states missing✓ OKAll five states defined
- Define empty, loading and error states for components that show data MUSTUI-R09
- Give the empty state a heading and an action that resolves it, and the error state a plain message and a way to recover, such as retry. Users know what to do next when there is no data or something fails.
- Check:
UI-03UI-03Empty, loading, error✕ NGNothing is shown when empty✓ OKHeading and a next action
- Define four states for form components and show errors in text MUSTUI-R10
- Draw the placeholder, filled, error and success states, with an error text layer in the error state. People who cannot tell colors apart still learn what is wrong.
- Check:
UI-04UI-04Error shown in text✕ NGError is only a red border✓ OKError is also shown in text
- Show selected and expanded states with a change of shape (an icon, an underline and the like), not only color MUSTUI-R11
- Combine color with something that changes shape, such as a check mark or arrow icon, an underline or a thicker border. Selected and unselected must stay distinguishable in grayscale. The current state is clear however colors are perceived.
- Check:
UI-05UI-05Selected state not by color alone✕ NGCannot tell which is selected✓ OKSelected tab has underline and bold
- Express the disabled state with the
disabledattribute oraria-disabled="true"MUSTUI-R12 - Fading the color alone does not tell screen reader users that the control cannot be used. The attribute makes assistive technology announce it as disabled.
- Check:
UI-10UI-10Disabled exposed✕ NGFaded color alone: not disabled✓ OKAnnounced as disabled
- Define the remaining-count display and the limit-reached state for inputs with a character limit SHOULDUI-R13
- When users see how much is left while typing, they do not have to rewrite after going over the limit.
- Check:
UI-12UI-12Character limit✕ NGNo count, no limit state✓ OKRemaining count and limit state
- Define how long auto-dismissing notifications stay on screen SHOULDUI-R14
- With the duration in the spec, no toast disappears before it can be read.
- Check:
TST-05TST-05Cap and display time✕ NGToasts pile up without limit✓ OKState both in the spec
Naming Convention
Use a consistent layer-naming convention in design tools so that engineers can map states programmatically:
ComponentName / State / Variant
Button / Default / Primary
Button / Hover / Primary
Button / Focus / Primary
Button / Disabled / Primary
Input / Placeholder
Input / Filled
Input / InvalidState Machine Approach
For complex components, document states as a finite-state machine before designing or coding.
[Empty] → fetch triggered → [Loading]
[Loading] → success → [Populated]
[Loading] → failure → [Error]
[Error] → retry → [Loading]
[Populated] → user action → [Loading]Representing states this way makes missing transitions visible and prevents impossible state combinations from reaching users.