Skip to content

Typography Components

[04] Typography Components

Link

Renders an accessible and themeable anchor link for navigation. Use this to direct users to other pages or external websites.

SourceEdit this page

Use Link for inline links in running text, footers and help copy. When it opens a new tab through external or target="_blank", it appends a visually hidden "(opens in new window)" note for screen readers, unless an aria-label is set. For navigation in a sidebar or header, use NavLink; for a call to action styled as a button, use Button, which also renders <a> when given href.

Basic usage

Link renders a styled anchor element for navigation. Unlike other typography components which default to inheritAppearance, Link renders its blue link color by default (no explicit appearance) with underline, and ships with focusVisible on for a keyboard focus outline.

<Link href="#">Click here to learn more</Link>

Appearances

Links render their blue link color by default. Set an explicit appearance to override: primary, accent, secondary, tertiary, success, danger, warning, info.

<Row flexWrap>
<Link primary href="#">Primary</Link>
<Link accent href="#">Accent</Link>
<Link secondary href="#">Secondary</Link>
<Link success href="#">Success</Link>
<Link danger href="#">Danger</Link>
<Link warning href="#">Warning</Link>
<Link info href="#">Info</Link>
</Row>

Variants

Link renders its own link colour rather than an appearance by default. Like all typography, Link is background-less: filled paints no surface behind it, and with an explicit appearance the text colour matches outline.

<Row flexWrap itemsCenter>
<Link href="#">outline, the default</Link>
<Link filled info href="#">filled info</Link>
<Link filled success href="#">filled success</Link>
</Row>

Size inherits from context

Link defaults to inheritSize: true so a link inside a heading renders at the heading's font-size automatically. No size prop needed. The link keeps its own blue colour.

Body text with a link inline.

Subheading with a link inside.
Section heading with a link.
Page title link
<Col>
<Text>Body text with a <Link href="#">link inline</Link>.</Text>
<Title>Subheading with a <Link href="#">link</Link> inside.</Title>
<SectionTitle>Section heading with a <Link href="#">link</Link>.</SectionTitle>
<PageTitle>Page title <Link href="#">link</Link></PageTitle>
</Col>

Fixed size with noInheritSize

Pass noInheritSize to render the Link at its own size instead of the parent's, useful when a link inside a heading should stay at body-text size.

Subheading with a fixed-size link mid-sentence.
<Title>
Subheading with <Link href="#" noInheritSize>a fixed-size link</Link> mid-sentence.
</Title>

Explicit sizes

An explicit size, xs, sm, md (default), lg or xl, renders the Link at that size instead of the parent's. Pass inheritSize alongside it to keep following the parent.

<Col>
<Link href="#" xs>Extra small link</Link>
<Link href="#" sm>Small link</Link>
<Link href="#" md>Medium link</Link>
<Link href="#" lg>Large link</Link>
<Link href="#" xl>Extra large link</Link>
</Col>

Styling

Use fontBold, fontSemibold, or italic for emphasis, or noUnderline to remove the default underline.

<Col>
<Link fontBold href="#">Bold link</Link>
<Link fontSemibold href="#">Semibold link</Link>
<Link italic href="#">Italic link</Link>
<Link noUnderline href="#">Link without underline</Link>
</Col>

Hover state

Links keep an underline at rest. With noUnderline, the underline appears on hover for affordance. Links also render a keyboard focus-visible outline by default for keyboard users (opt out with noFocusVisible).

<Col>
<Link href="#">Underlined at rest, stays underlined on hover</Link>
<Link noUnderline href="#">No underline at rest, hover to reveal it</Link>
</Col>

External links

Pass the external prop and Link auto-applies target="_blank" and rel="noopener noreferrer" for safe cross-origin navigation.

<Link href="https://github.com/vaneui/vaneui" external>VaneUI on GitHub</Link>

Manual target="_blank"

Setting target="_blank" directly also auto-applies rel="noopener noreferrer". No need to spell it out.

<Link href="https://github.com/vaneui/vaneui" target="_blank">Open in a new tab</Link>

Inline in Text

Links integrate naturally with surrounding prose. Drop them inline inside Text and they inherit the parent size.

Check out our documentation to learn more about the features. You can also visit the GitHub repository for source code.

<Text>
Check out our <Link href="#">documentation</Link> to learn more about the features.
You can also visit the <Link href="#">GitHub repository</Link> for source code.
</Text>

Link is inline, so marginT, marginB, and marginY have no visual effect. Use marginX for inline-side spacing, or className for an exact value.

Inherits parent Text size

Links inside body text inherit the surrounding Text size. Set the size on the parent and the Link follows along.

Read the terms and conditions before proceeding.

Visit our help center for more information.

Check out the getting started guide to begin.

<Col>
<Text sm>Read the <Link href="#">terms and conditions</Link> before proceeding.</Text>
<Text>Visit our <Link href="#">help center</Link> for more information.</Text>
<Text lg>Check out the <Link href="#">getting started guide</Link> to begin.</Text>
</Col>

With icons

Combine links with icons using Row for visual navigation cues.

<Col>
<Row itemsCenter>
<ExternalLink size={14} />
<Link href="#">Open in new window</Link>
</Row>
<Row itemsCenter>
<FileText size={14} />
<Link href="#">View documentation</Link>
</Row>
<Row itemsCenter>
<GitHub size={14} />
<Link href="#">Source on GitHub</Link>
</Row>
</Col>

Next.js Link integration

Use the tag prop to render the VaneUI Link as a Next.js Link for client-side navigation. Alias the Next.js import so it doesn't shadow Link from @vaneui/ui.

import NextLink from 'next/link';
import { Link } from '@vaneui/ui';
<Link href="/docs" tag={NextLink}>Documentation</Link>

Customizing

Set app-wide Link defaults with ThemeProvider's themeDefaults:

<ThemeProvider themeDefaults={{
link: { info: true, noUnderline: true },
}}>
<Link href="/docs">Read more</Link>
</ThemeProvider>

Frequently asked questions

How do I change the link color across the site?

Re-declare the --color-text-link token, which every Link without an appearance reads. For a site with dark mode, set it as a light-dark() pair on the data-theme elements and the light value on :root, as described under Changing a color in both schemes. To give every link an appearance color instead, use themeDefaults={{ link: { info: true } }}, as under Customizing.

How do I disable a Link?

Pass disabled. An <a> has no native disabled state, so Link removes the href, blocks clicks and Enter, and sets aria-disabled="true". The link stays focusable, so a screen reader user still finds it and hears that it is unavailable. Say near the link why it is disabled, since a disabled link gives no reason of its own.

Why is my Link in a different font from the text around it?

Link is fontSans by default, so inside a Text with fontSerif or fontMono, or a heading whose --font-heading names another font, it switches to the sans font. Give the Link the same font prop as its parent, such as fontMono or fontHeading, or set that font on the link node in themeDefaults to change every Link.