Skip to content

Link

A styled anchor that opens external links in a new tab, with an arrow to say so.

Deploys roll out region by region. Read the rollouts guide to choose the order, or check the status page (opens in a new tab) for incidents.

Installation

  1. Add the registryOnce per project
  2. Add link

Usage

A link whose href is an absolute URL, such as https://example.com, opens in a new tab. It gets rel="noopener noreferrer" and an arrow after its text, and screen readers announce "(opens in a new tab)" after its name. Relative paths, fragments, mailto: and tel: links open in place.

Link can render in a server component. Use it for navigation. For an action that looks like a link, use a Button with variant="link".

Examples

Variants

default underlines the link in the foreground color. muted matches the links inside other components' descriptions, such as a Card's. plain keeps the color of its surroundings and underlines the link only on hover, for lists of links such as a footer.

Pass external to open any link in a new tab, such as a PDF on your own site, or external={false} to keep an absolute URL to your own site in the same tab. A target you pass yourself always wins, and a link with target="_blank" shows the arrow too.

An external link adds the rel you pass to its own, so rel="me" on a link to your profile renders rel="noopener noreferrer me". To keep the referrer, pass external={false} with your own target="_blank" and rel="noopener".

Without the arrow

Pass externalIcon={false} to hide the arrow where every link opens in a new tab, such as a row of links to other sites. Screen readers still announce newTabLabel.

Routers

To navigate with your router, pass its link to render. Link merges its class names and attributes into the router's <a>. It reads href to decide whether a link is external, so a router link that takes to stays in the same tab. Use Link with href for external URLs.

Wrap Link once with next/link, so href reaches both of them.

components/app-link.tsx

A link with aria-current="page" turns the foreground color. TanStack Router sets it on the active link. With other routers, set it yourself.

Props

Base UI's styling (opens in a new tab) and composition (opens in a new tab) guides say more about className, style and render.