Skip to main content

Skip to Main Link

A visually-hidden-until-focused "skip link" that lets keyboard users jump past repeated navigation and land directly on the page's main content landmark. Pair it with the Main component (or any element with a matching id and tabIndex={-1}) so the target can receive focus.

When to use

  • Let keyboard users jump past repeated navigation to the main content of the page.
  • Prefer VisuallyHidden when the hidden content is text for screen readers, not a link.

Placement and focus

Place the link at the top of the document, before the navigation it skips.

When activated, the link focuses the element identified by targetId (defaulting to "main"). It updates the URL hash with the browser History API, so it works in any framework, including React Router, Next.js, or plain HTML.

The focus call scrolls a target that sits off screen into view, so a sighted keyboard user sees where focus went. A target already in view does not move.

API Reference

Renders an anchor element that is visually hidden until focused. Accepts all standard <a> HTML attributes except href, which is derived from targetId.

PropTypeDefaultDescription
targetId?string"main"The id of the element to focus when activated. The link's href is set to #${targetId}.
children?ReactNode"Skip to main content"The label displayed when the link is focused.
Data AttributeValueDescription
data-slot"skip-to-main-link anchor"Names the part, joined after any chain a composing ancestor passes and ahead of Anchor's own slot.