VIS-008b Keep a selected or on state visible while the item is hovered, focused or pressed
- Level
- Rule
- Verdict
- Unanimous (3 of 3)
- Status
- proposed, version 1.0.0
Rule
A state that lasts, such as selected, checked, on or current, stays visible while the same item is also hovered, focused or pressed. The look of hover, focus or press is never the same as the look of a state that lasts.
Examples
Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.
Do: A toggle that stays on under the pointer
aria-pressed:hover:bg-primary/90; the hover fill is kept for items that are off. In the stills "Selected + hover" is not "Hover". Hover Bold and Italic in turn.Don't: A hover that wipes out the selection
hover:bg-accent, so the item that is on turns into any other hovered item. In the stills "Selected + hover" and "Hover" are the same picture. Point at Bold: the one place you check what you chose is where it looks unchosen.Do: A chosen plan that keeps its marks under the pointer
Plan
Don't: A chosen plan drawn with the focus ring
Plan
ring, the look of focus, and nothing else. In the stills, "Selected" and "Focused, not selected" look alike. Live, Tab away from the plans: the chosen plan still wears what looks like the focus ring, so you cannot tell where focus is.Why
Hover, focus and press come and go with the pointer, the keyboard and the finger. Selected, checked, on and current stay until the person changes them. If the passing look wipes out the lasting one, the selected item turns into any other hovered item the moment the person points at it, which is exactly when they are checking what they chose. If the two looks are the same, the person cannot tell the item they chose from the item under the pointer, or from where the keyboard is. They may leave believing the wrong plan is chosen, or press a toggle again because it seemed already on. No WCAG criterion asks that states combine or differ from each other. WCAG 2.2, 1.4.11 Non-text Contrast only adds that a hover must not make the cue for focus or selection lose contrast, which VIS-004 carries, and 1.4.1 Use of Color supports keeping a cue that does not rest on a tint. The rule rests on the judges.
Do
- Let the looks add up. In a toolbar's
ToggleGroupfor Bold, Italic and Underline, an item that is on keeps its on look while hovered: scope the hover to items that are off, as indata-[state=off]:hover:bg-muted, or give the on state a hover of its own, such asdata-[state=on]:hover:bg-primary/90where on isbg-primary. - On a pricing page, the chosen plan card carries a check icon and the text "Selected", as VIS-003a asks. Hover changes only the card's fill, so the check and the word are still there under the pointer.
- When the same token draws hover and selected, which VIS-002 allows for
bg-accent, give the selected item a cue the hover does not use, such as a check, a bar beside it or heavier text. VIS-002 picks the token, VIS-003a asks for the second cue, and this rule keeps the two looks apart and the lasting one in place. - In a data table with selectable rows, keep the checkbox column. A selected row in
bg-mutedand a hovered row inbg-muted/50differ only slightly, and the checked box is what shows the selection under the pointer. - A selected item that gets focus shows both: the focus indicator that KBD-001 describes and its selected look.
- In
Select,Commandand menus, the highlighted row under the pointer or keyboard getsbg-accent, and the chosen value shows a check. Keep it that way. The highlight moves; the chosen value must not depend on it. - In a sidebar, hovering the current page's item does not remove its mark. shadcn's
SidebarMenuButtondraws bothdata-[active=true]:andhover:withbg-sidebar-accent, so under the pointer any item looks current unless the current one keeps another mark, such as itsfont-mediumor a bar beside it. The mark itself is NAV-002b. - Style the lasting state from the state in code, as in
aria-pressed:ordata-[state=on]:. That is VIS-008a's own advice, and it also keeps the selected look from drifting when the hover classes change.
Don't
- Give the selected item
bg-primary text-primary-foregroundand every itemhover:bg-accent hover:text-accent-foreground, so the selected item looks like any other once the pointer is on it. - Mark a chosen card with
ring-2 ring-ring, the look of focus. VIS-002 keepsringfor focus. - Draw focus as
focus:bg-accenton items whose selected look is also onlybg-accent. - Give Undo in a toolbar the same
active:fill that Bold uses for on, so a press on Undo looks like a toggle switching on. - Hide the check on the chosen option with
group-hover:hiddenand show an arrow in its place.
Exceptions
- The change itself. When a press switches a toggle on or off, the lasting look changes, as it should. The rule asks only that hover, focus and press do not hide or imitate it.
- How far apart. How much the looks must differ is not set here. A state told by colour alone is VIS-003a, and the contrast of a state mark, also while hovered, is VIS-004.
- Neighbouring rules. Whether hover and press looks exist at all is VIS-008. The focus look is KBD-001. The current page's mark is NAV-002b. The state in code is VIS-008a.
Verdict
Unanimous (3 of 3). Only the judges decide; the expert witnesses are shown but do not vote. How verdicts work
| Source | Role | Stance | Page |
|---|---|---|---|
| WCAG 2.2 | Law | Supports | 1.4.11 Non-text Contrast |
| WCAG 2.2 | Law | Supports | 1.4.1 Use of Color |
| Material Design | Judge | Supports | States: applying states Lists: guidelines Lists: accessibility |
| Apple Human Interface Guidelines | Judge | Supports | Focus and selection (ipados, macos, tvos, visionos; not ios or watchos; no web guidance) Toggles (all; no web guidance) |
| Carbon Design System | Judge | Supports | Color Tile |
| GOV.UK Design System | Expert witness | No position | |
| Nielsen Norman Group | Expert witness | Supports | Button States: Communicate Interaction, by Kelley Gordon |
Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.
History
- Version 1.0.0, : First version.
Last checked against the other rules for conflicts on .
More in Colour and motion: 11 rules and 0 guidelines · All rules
Justified is an independent project. It is not affiliated with, sponsored or endorsed by the organisations whose guidance it cites. Read the full statement.
Apple is a trademark of Apple Inc., registered in the U.S. and other countries and regions.