Skip to main content

Link

Navigates somewhere else, inline or in chrome, with real link semantics.

import { Link } from "@/fragments/ui";Source

Preview

<Link href="#">Learn more about our services</Link>

Installation

npx @usefragments/cli add link

Writes src/fragments/ui/components/Link plus what it imports, the globals stylesheet, and .fragments/registry-lock.json, then prints the packages to add. No account, no key.

Your own registry: publish from Fragments Cloud and add --registry org/name. Connect a workspace.

Examples

Tones

Accent, then neutral, then the quietest neutral.

import { Stack } from '@/components/Stack';

<Stack direction="row" gap="md" align="center" wrap>
  <Link href="#" tone="accent">Accent</Link>
  <Link href="#" tone="neutral">Neutral</Link>
  <Link href="#" tone="neutral" color="tertiary">Tertiary</Link>

Underline Styles

Four rules for when the line shows.

import { Stack } from '@/components/Stack';

<Stack direction="row" gap="md" align="center" wrap>
  <Link href="#" underline="always">Always underlined</Link>
  <Link href="#" underline="hover">Underline on hover</Link>
  <Link href="#" underline="dotted">Dotted underline</Link>

Sets target and rel; you still supply the visible cue.

<Link href="https://example.com" external>
  View documentation ↗
</Link>

As Child (Polymorphic)

Paints Link styling onto a router link and keeps both click handlers.

<Link asChild tone="neutral" onClick={() => {}}>
  <a href="#pricing" onClick={() => {}}>
    Client-side navigation
  </a>
</Link>

API

Component props
Prop
Type
Default
Description
childrenRequirednodeNot setLink text content
toneenumaccentneutralaccentColour. accent is the link ink; neutral reads as body text until hovered
colorenumprimarysecondarytertiaryNot setText-hierarchy colour for a neutral link (Text color axis); tertiary is the quietest link
underlineenumalwayshovernonedottedhoverUnderline behavior
externalbooleanfalseOpens in new tab with noopener noreferrer
asChildbooleanfalseRender as child element (polymorphic). Merges link props/classes and composes event handlers onto the single child (e.g. Next.js Link).
classNamestringNot setAdditional class name
styleobjectNot setInline styles
targetunionNot set
relstringNot set

Accessibility

  • The link text alone should make sense out of context
  • Say when a link opens a new window
  • Focus ring must stay visible
  • A link that looks like a button still needs link semantics

Guidance

Use when

  • Inline links inside body text
  • Footer and sidebar navigation
  • "Forgot password?" and "Sign up" in forms
  • Pointing out to docs or external resources

Avoid when

  • A main call to action — use Button
  • Switching views in place — use Tabs
  • Dropdown items — use Menu
  • ButtonalternativeUse Button for primary actions, Link for navigation
  • TextparentLinks often appear within Text components

Next steps