Link

A text link: in running text, under a form ("Create an account"), in a footer (Terms, Privacy). It goes somewhere; an action that does something is a button.

Anatomy

a.rounded-chip.font-medium.underline[href]       target, rel only with external
├── slot
└── (external) svg[aria-hidden] + span.sr-only " (opens in a new tab)"

Nothing is printed before the a or after it, and the view has no newline at its end, so a link followed by a full stop or a bracket has no space before it.

Variants

variantColourHoverFor
defaultaccentaccent-hoverA link in running text
mutedfg-bodyfgThe quiet ones: Terms, Privacy, "Use a different email"
dangeron-danger-tintthe underline darkensA link to something destructive

Every colour is 4.5:1 or more on surface, surface-subtle and surface-sunken, in both themes (npm run test:tokens checks the pairs). fg-muted and danger were under AA on the app's ground until 2.0 (4.39:1 and 4.33:1), which is why the muted and danger links use fg-body and on-danger-tint; both tokens now pass there too (4.60:1 and 4.62:1).

The underline is always there, at 40% of the text colour, and full strength on hover: colour alone does not mark a link (WCAG 1.4.1), and a link set in the body colour has only its underline.

Size

No size takes the text size around it, the usual case in prose. sm (text-meta) and md (text-body) set one, for a link standing alone.

External

external adds target="_blank" rel="noopener noreferrer", an arrow (micro arrow-top-right-on-square, hidden from screen readers) and externalLabel, "(opens in a new tab)" by default, as hidden text: a new tab is a change of context the reader should hear about before it happens.

Focus

focus-visible:outline-2 outline-offset-2 outline-focus-ring, on the rounded-chip corners. There is no outline-none before it.

Do not

  • Do not use it without href (it throws): something that does an action is a button.
  • Do not style a ghost button as a link, or a link as a ghost button. A button is a box you press; a link is words you follow.
  • Do not set target="_blank" by hand: external adds the rel and says so to a screen reader.

From the package repo: edit this page on GitHub.

Was this page helpful?