Skip to main content
On this page

An anchor link for navigating to pages or anchor points within prose

When to use​

  • For navigation links embedded within body text, such as references, further reading, or related pages
  • For standalone navigation links where a full button-style target is not appropriate
  • When linking to an anchor point within the same page

When not to use​

  • To trigger an action such as submitting a form or opening a modal - links navigate; buttons act. Use CTA Button instead.
  • As a primary or secondary call to action - use CTA Link instead, which has the visual prominence of a button while remaining an anchor element.
  • When the link label would be non-descriptive - do not use "click here", "read more", or "find out more" as link text. Rewrite the surrounding sentence so the link label describes the destination.

Anatomy​

  1. Link text (the visible, underlined label)
  2. External indicator (an icon and visually hidden text appended when opensInNewWindow is true)

Basic usage​

Loading...
Edit live code
<TextLink
  href="https://friendsoftheearth.uk/climate-change/live-sustainably-how-be-conscious-consumer"
>How to be a conscious consumer</TextLink>

Variants and features​

TextLink is designed to sit within prose. Place it inside a Text (P) element so it inherits body font size and color context correctly.

The underline is always visible on TextLink. This is intentional: removing underlines from inline links reduces their discoverability for users with colour vision deficiencies.

Loading...
Edit live code
<P>Visit <TextLink
  href="https://friendsoftheearth.uk/climate-change/live-sustainably-how-be-conscious-consumer"
>Friends of the Earth</TextLink> for more information.</P>

Opening in a new window​

Use opensInNewWindow when the link genuinely needs to open in a new browser tab, such as a link to an external site or a document that the user needs to reference while staying on the current page. Do not use it by default. Opening links in new windows removes the user's ability to navigate back and is unexpected behaviour for most links.

When opensInNewWindow is true, the component automatically appends a new-window icon and a visually hidden " (opens in new window)" text disclosure so screen reader users are informed before activating the link.

Loading...
Edit live code
<TextLink href="https://www.ofgem.gov.uk" opensInNewWindow>
  Ofgem price cap information
</TextLink>

For links to external domains, TextLink automatically adds rel="noopener" to prevent the linked page from accessing the opener's window object. This happens based on whether the href is detected as an external link. No extra configuration is needed.

React Router integration​

Pass the React Router Link component via the as prop to use client-side navigation while keeping the visual style of TextLink.

This example is not live, because the docs site does not use React Router.

import { Link } from 'react-router-dom';

<TextLink as={Link} to="/account">
View account
</TextLink>