Skip to content

Colour contrast and motion patterns for shadcn

Rules / Colour and motion: 11 rules and 0 guidelines

Colour and motion are where a theme meets the eyes of the person using it. A grey that looks calm on a good screen can be unreadable in sunlight, and a panel that slides in smoothly for one person brings on dizziness in another. shadcn’s theme gives every colour a name, such as muted-foreground or border-input, and tw-animate-css gives every overlay an entrance. Neither checks what a colour is drawn on once opacity is added, says whether red is the only sign of an error, or stops a carousel. Justified’s contrast test measures the token pairs in both themes; the rules here keep that true in the rest of the app.

Where colour and motion go wrong

  • opacity-50 on a timestamp, or white text on a photo with no scrim, checked only against the token on paper. VIS-001
  • Raw palette classes such as text-gray-400, or a foreground token on a fill it was never paired with. VIS-002
  • A status shown as a green or red dot, or an active tab told apart only by its text colour. VIS-003a
  • A link in a paragraph that is coloured but not underlined, or underlined only on hover. VIS-003b
  • A field edged with border-border, so its outline barely shows against the page. VIS-004
  • A clickable card that looks the same under the pointer and when pressed, or a selected tab whose mark disappears on hover. VIS-008, VIS-008b
  • A toggle that looks pressed but has no aria-pressed, so a screen reader hears no state. VIS-008a
  • A carousel or a logo strip that moves forever with nothing to press. VIS-005
  • Panels that slide and zoom for someone who has asked their system for less motion. VIS-006
  • A shake as the only sign of a wrong password. VIS-007

How the rules fit together

Three rules cover contrast. VIS-001 sets it for text: 4.5:1, or 3:1 for large text, against the colour the browser actually paints, after opacity, overlays and images, and in every state. VIS-004 sets 3:1 for what people need to see to find a control and tell its state, such as a field’s edge, a checkbox’s tick or a switch’s track, and for the parts of a graphic they need. VIS-002 is how both stay true: every colour that marks something has a role, and each token is used only for that role and the pairs it was made for. A pair the product needs and does not have is added to the tokens and measured, not borrowed.

Two rules keep colour from carrying meaning alone. VIS-003a says a meaning or a state, such as a status, an error or a selection, always has a second sign: text, an icon, a shape or a pattern. VIS-003b is the narrower case of a link in running text, which stands out from the words around it at rest by more than colour; with Justified’s tokens that means an underline. The current page in a menu is the same idea applied to navigation (NAV-002b).

Three rules cover how a control shows its state. VIS-008 changes the look of everything people can press while it is pressed and while the pointer is over it. VIS-008b keeps a state that lasts, such as selected or on, visible during hover, focus and press, and never lets those look like it. VIS-008a sets every state the control shows in code on the control as well, and changes it whenever the look changes.

Three rules cover motion. VIS-005 gives a way to pause, stop or hide content that starts by itself and moves for more than five seconds, or that updates by itself. VIS-006 swaps movement for a short fade or an instant change when the person’s device asks for reduced motion. VIS-007 makes sure that whatever an animation means is also shown in text, an icon or a state that stays. The setting and the pause control do different jobs, so one never stands in for the other. Loaders are STA-001’s, and the focus indicator is KBD-001.

What WCAG requires and what the judges decide

Six rules here come from WCAG 2.2. Text contrast follows from 1.4.3 Contrast (Minimum), non-text contrast from 1.4.11 Non-text Contrast, colour as the only sign and links in text from 1.4.1 Use of Color, pausing motion from 2.2.2 Pause, Stop, Hide, and a state set in code from 4.1.2 Name, Role, Value. For these the law decides. The judges who spoke supported each of them, all three in the case of text contrast.

The other five are decided by the judges; no Level AA criterion requires them. Colour tokens used by role, reduced motion, a change on hover and press, and a lasting state that stays visible had all three in support, and motion that is never the only sign had both who spoke. Reduced motion is asked for at Level AAA, in 2.3.3 Animation from Interactions, which VIS-006 treats as a further aim, not a requirement.

Rules and guidelines

Each one has its own page with the full rule, Do and Don't cases, exceptions and the verdict. A rule is decided by WCAG 2.2 or by the judges. A guideline is our own choice. How the method works

Required by WCAG 2.2

A WCAG 2.2 Level AA criterion requires the behaviour. Where a rule adds advice of its own, it says so.

Decided by the judges

No WCAG criterion requires these. The judges who spoke support them, all or most of them.

All rules · Is shadcn accessible? · Give the rules to an AI agent

Justified by Blackwood & Blake helps you work toward WCAG 2.2 AA. It is not a certification. Read more