Skip to content

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 and with state definitions
Without State DefinitionWith State Definition
Developers invent hover/focus styles ad hocExact colours, cursors, and animations are specified
Empty and error states are shipped as blank areasPlaceholder copy and recovery guidance are reviewed before build
Loading is handled by a spinner thrown in at the last minuteSkeleton screens or progress patterns are deliberately chosen
Accessibility reviewers find missing aria-* states post-launchRequired 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 ​

Interaction states
StateTriggerWhat to Specify
DefaultNo interactionBackground, border, text colour, cursor
HoverPointer over elementVisual change that does not rely on colour alone; cursor: pointer for links/buttons
FocusKeyboard focusoutline or equivalent focus ring; visible (WCAG 2.4.7), with at least 3:1 contrast against adjacent colors (WCAG 1.4.11)
Active / PressedMouse/touch downDistinct feedback from hover; scale or background shift
DisabledFunctionally unavailablecursor: 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 ​

Data and content states
StateDescriptionWhat to Specify
EmptyNo data to displayIllustration or icon, heading, helper copy, and a primary action to break the empty state
LoadingAsync data pendingSkeleton screen (preferred) or progress indicator; duration threshold for showing it
Partial / PopulatedSome but not all data presentPagination or progressive-disclosure pattern
Full / Limit ReachedMaximum capacityInline message explaining the limit and any remediation path
Error / FailedOperation or data fetch failedError icon, plain-language message, and recovery action (retry / contact support)
Success / CompletedOperation succeededConfirmation copy; auto-dismiss timing if using a toast

Form-Specific States ​

Form-specific states
StateElementWhat 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
InvalidAny form controlRed border alone is insufficient; inline error message below the field linked via aria-describedby
ValidAny form controlOptional green indicator only after initial submission attempt; avoid premature validation
RequiredAny form controlAsterisk * 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-allowed or default). Developers do not have to invent undefined states on the spot.
Check: UI-02UI-02 Five interaction states✕ NGFocus and 2 more states missingButton defines only default and hover✓ OKAll five states definedButton defines default, hover, focus, pressed and disabled
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-03 Empty, loading, error✕ NGNothing is shown when emptyEmpty state is blank, with no heading or action✓ OKHeading and a next actionEmpty state has a heading and an Add booking button
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-04 Error shown in text✕ NGError is only a red borderInput turns red but has no error text✓ OKError is also shown in textRed border plus an error text below the input
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-05 Selected state not by color alone✕ NGCannot tell which is selectedIn grayscale, selected and unselected tabs look the same✓ OKSelected tab has underline and boldIn grayscale, the selected tab keeps its underline and bold text
Express the disabled state with the disabled attribute or aria-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-10 Disabled exposed✕ NGFaded color alone: not disabledA button only faded with CSS is read as "Send, button"✓ OKAnnounced as disabledA button with the disabled attribute is read as "Send, dimmed, button"
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-12 Character limit✕ NGNo count, no limit stateInput with a character limit shows no remaining count✓ OKRemaining count and limit stateThe input shows the remaining count and has a limit-reached 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-05 Cap and display time✕ NGToasts pile up without limitNo maximum count or display time is defined, so toasts pile up✓ OKState both in the specThe spec sets a maximum of 3 and 5 seconds, and at most 3 are shown

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 / Invalid

State 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.