Skip to content

Components · Navigation

BackLink

A link to the parent page with a leading back arrow; works with any router.

@rookcom/monarch-reactComponent

Variants

Usage examples

With a router link

Purpose

Takes the reader one level up from a detail page (“Back to domains”, “All invoices”) with a consistent arrow, colour, focus ring and touch target.

Use when

  • A detail or settings page has a single, known parent list.
  • Breadcrumbs would be one item deep.

Avoid when

  • The hierarchy is two or more levels deep: use Breadcrumb.
  • You need browser history (“wherever I came from”): that is a product decision; pass the resolved href or handle onClick yourself.

Design principles

  • Name the destination, not the direction: “Back to domains” beats “Back”.
  • Quiet by default (subtle): it sits above the page title and must not compete with it.
  • Router-agnostic: asChild styles the product’s own link component, the same way Link and Button do.

API reference

import { BackLink } from '@rookcom/monarch-react';
ExportKindRenderingRoot class
BackLinkcomponentserver-safe.mn-back-link

Forwards its ref to the <a> (or the child element with asChild). All native anchor attributes pass through.

With asChild, the arrow is inserted before the child’s own children through Radix Slottable.

Generated from the TypeScript declarations of packages/react/src/components/navigation/back-link.

Properties

A link to the parent page, with a leading back arrow. Works with any router through `asChild`.

PropTypeDescription
children requiredReactNodeThe destination, named in the text: "Back to domains", "All invoices".
asChildbooleanRender the child element (e.g. a Next.js `<Link>` or React Router `<NavLink>`) with back-link styling and the arrow, instead of an `<a>`.
classNamestring
idstring
variant"subtle" | "standalone"`subtle` (default) is muted text that darkens on hover; `standalone` uses the link colour.

Variants

PropValuesDescription
variant'subtle''standalone'subtle is muted text that darkens on hover; standalone uses the link colour and underlines on hover (data-variant).

States

StateExposed asBehaviour
Hover–Text darkens (or underlines) and the arrow nudges 2px towards the start edge.
Focus–Visible focus ring on :focus-visible only.

Interaction behaviour

  • Native link behaviour: click, Enter, middle-click and “open in new tab” all work.
  • With asChild, navigation is handled by the router link you pass.

Keyboard support

KeysAction
TabMoves focus to the link.
EnterFollows the link.

Accessibility

Role
link
Accessible name
The visible text.
  • The arrow is aria-hidden, so it never adds “left arrow” to the name.
  • Minimum height of 24px meets WCAG 2.2 target size (2.5.8).
  • The arrow mirrors in right-to-left documents (dir="rtl").

Responsive behaviour

  • Inline size; the text may wrap on narrow screens, with the arrow centred beside it.

Theme support

  • subtle uses --mn-color-text-muted and --mn-color-text-default on hover; standalone uses --mn-color-text-link. Both meet AA in every theme.
  • The arrow nudge is turned off under reduced motion.

Do and don't

  • Place it above the page title, aligned with the content edge.
  • Name the parent page in the text.
  • Do not use it for a “Cancel” action in a form: use a Button.
  • Do not show a BackLink and a one-item Breadcrumb together.
  • Breadcrumb: Deeper hierarchies.
  • Link: Inline and standalone text links.
  • PageHeader: The page title the back link sits above.

Dependencies

KindDepends on
npm packages@radix-ui/react-slotreact
Monarch componentsNone

Testing coverage

  • Is a link named by its text, with an aria-hidden arrow and the default variant.
  • Renders a router link with asChild, keeping the arrow, classes and variant.
  • Reachable with Tab and activated with Enter.
  • Forwards the ref.
CheckCovered
Axe in jsdomYes
Server renderingYes
Browser suitesVisual baselines: /__gallery; Cross-browser axe: /components/back-link

Tests: packages/react/src/components/navigation/back-link