VaneUI

VaneUI

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

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.

react-icon
<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.

react-icon
<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. filled puts the appearance's surface behind it, which is how you build a link that reads as a chip.

react-icon
<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

react-icon
<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.

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

Explicit sizes

When noInheritSize is set (or the parent has no size context), choose an explicit size with xs, sm, md (default), lg, xl.

react-icon
<Col>
<Link href="#" noInheritSize xs>Extra small link</Link>
<Link href="#" noInheritSize sm>Small link</Link>
<Link href="#" noInheritSize>Medium link (default)</Link>
<Link href="#" noInheritSize lg>Large link</Link>
<Link href="#" noInheritSize xl>Extra large link</Link>
</Col>

Styling

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

react-icon
<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).

react-icon
<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.

react-icon
<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.

react-icon
<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.

react-icon
<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.

react-icon
<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.

react-icon
<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.

react-icon
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:

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