Skip to main content

Design system components

Link

Accessible inline link with sm/md/lg/inherit sizes, a focus ring, URL sanitisation, and an optional external-link icon.

Status: stable. Group: navigation. Markdown version: /design-system/components/link.md

When to use

Link is the inline navigation anchor. It sanitises the href (http, https, mailto, tel and relative paths only; javascript: and data: URLs are rewritten to #), auto-detects off-site destinations and appends an external-link icon plus a translated visually hidden "(external link)" suffix, and adds rel=noopener noreferrer to every link it classifies as external, whatever the target (a relative target=_blank link gets no added rel). Detection is by URL shape alone, identical on server and client so hydration never diverges: every absolute or protocol-relative http(s) URL counts as external, including one that points at the current site, so use a relative href for same-site links. Underline modes cover always, hover and none; sizes are sm, md, lg and inherit (follows the surrounding text size).

Use Link for navigation in body copy, lists, breadcrumbs and footers; the plain underline treatment is token-driven.

When not to use

  • Do not use Link for actions. Buttons are for actions; anchors are for navigation.
  • Do not override the underline via inline styles; the token-driven treatment owns it.
  • Do not use underline=none for links in running text; an undecorated inline link loses its affordance.

Look-alikes

  • Button: Do not build button-shaped CTAs from Link; use Button, with href when the destination is a page.
  • NavLink: Do not use NavLink for inline body links; that is Link's job; NavLink's route tracking is navigation-chrome behavior.
  • SocialIconLink: Do not put text children inside; this is icon-only; use Link for labeled links.

Props

Link props
PropTypeDefaultDescriptionRequired
size"sm" | "md" | "lg" | "inherit"mdSize. Defaults to md; inherit follows the surrounding text size.No
underline"always" | "hover" | "none"alwaysUnderline mode. "always" shows it permanently, "hover" reveals it on hover and keyboard focus (nav lists like the site footer), "none" omits it entirely. Defaults to always.No

Variants

  • Available sizes: sm, md, lg, inherit (default md).
  • Allowed underline values: always, hover, none (default always).

Invalid combinations

The contract records no invalid combinations.

Keyboard

Link keyboard behaviour
KeyBehaviour
EnterActivates the focused control. (standard)

Rows marked (standard) name a key the contract lists without a description; the behaviour shown is the usual one for that key.

Rules

Every item under When not to use is a MUST NOT. MUST and SHOULD follow RFC 2119.

Link rules
LevelRuleHow it is checked
MUSTARIA: Visible focus.Not yet verified: no evidence record. WCAG 4.1.2.
MUSTARIA: Descriptive link text.Not yet verified: no evidence record. WCAG 4.1.2.
MUSTRequired stories produce no axe violations at the configured severity.Automated by npm run test:stories:matrix:ci. WCAG 2.5.8.
MUSTThe accessibility tree (role, name, state) matches the committed snapshot for every required story.Automated by npm run test:stories:matrix:ci. WCAG 1.3.1, 4.1.2.
MUSTThe component remains legible and operable under a real browser forced-colors: active pass.Automated by npm run test:stories:hc.
MUSTEvery documented keyboard interaction works as specified.Not yet verified: no evidence record. WCAG 2.1.1, 2.1.2.
MUSTA human completed an end-to-end accessibility review of this component.Manual review, last on 2026-11-04.
SHOULDLet the component detect external destinations; the icon and rel handling are automatic.Not stated in the contract.
SHOULDUse underline=hover in dense link collections such as footer columns.Not stated in the contract.
SHOULD NOTDo not build button-shaped CTAs from Link; use Button, with href when the destination is a page.Not stated in the contract.
SHOULD NOTDo not compose raw anchors for dynamic hrefs to bypass the sanitiser; a pasted URL must never become an XSS surface.Not stated in the contract.

Install and import

  • Install: npm install @digitaltableteur/react (version 0.9.1, restricted access on npm).
  • Import: import { Link } from "@digitaltableteur/react";
  • Entry point: @digitaltableteur/react/navigation exports it too.
  • Styles: import @digitaltableteur/react/style.css once at the app boundary.
  • Also available as the custom element <dt-link>; see the custom elements manifest.