Skip to content

Error, tooltip and link text patterns for shadcn

Rules / Text: 4 rules and 0 guidelines

Much of an interface is words: the message after something fails, the hint that appears on hover, the text of a link. A component can draw the words, but it cannot choose them, and it cannot tell whether what it hides behind a hover is something people need. This area covers the words people read while they work and the small pieces of content that appear and disappear around them.

Where text goes wrong

  • “Something went wrong” or “Invalid input”, which leave people with no idea what failed or what to do. TXT-001a
  • An error that uses a code or a field name from the database instead of the label the person sees on screen. TXT-001a
  • A tooltip that vanishes when the pointer moves towards it, or that cannot be closed without moving away. TXT-002a
  • A tooltip that opens on hover but not when the trigger gets keyboard focus, or a trigger that cannot take focus at all. TXT-002b
  • The format a field needs, or the reason a button is unavailable, hidden in a tooltip. TXT-002b
  • A page full of links that all say “Read more” or “Click here”. TXT-003

How the rules fit together

TXT-001a is about messages that report a problem. Each one says in plain words what went wrong, names the thing it concerns by the name the person sees, and gives a next step: the fix if it is known, otherwise a retry, a wait or where to get help. It applies wherever the message appears: at a field (FRM-002a), in the area where an action failed (FBK-002) or next to a submit button that is unavailable (ACT-005).

TXT-002a and TXT-002b go together. The first sets how content that appears on hover or focus behaves: it can be closed without moving, usually with Escape, the pointer can move onto it, and it stays until the person is done with it. The second sets what such content may hold, and when it opens. A tooltip opens on keyboard focus as well as on hover, and it holds only extra help. Anything the person needs to finish the task is on the page.

In shadcn, a tooltip meant to explain a disabled button never opens at all, as Is shadcn accessible? explains. Put the explanation on the page instead, as ACT-005 says.

TXT-003 is about links. People must be able to tell where a link goes, or what it opens, from its text, from its accessible name, or from its text together with the sentence, list item or table cell around it. When a short visible word has to stay, a visually hidden addition inside the link can complete it, as long as the visible words stay part of the name. How a link in running text stands out from the words around it, by an underline rather than colour alone, is VIS-003b in the colour patterns. An image that is a link is named after where it goes, and the page structure patterns cover the text of other images (STR-005) and the words of headings (STR-002b).

What WCAG requires and what the judges decide

Two rules here come from WCAG 2.2. Content on hover or focus follows from 1.4.13 Content on Hover or Focus, and link text from 2.4.4 Link Purpose (In Context) and 2.5.3 Label in Name.

The other two are decided by the judges. Messages that say what went wrong, what it concerns and what to do next had all three in support. Tooltips that open on focus and hold only extra help had both judges who spoke. Radix’s tooltip already opens on focus and closes with Escape; what goes into it is still up to you.

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