Skip to main content
The Link component is a primitive anchor element with theme-aware styling and variant support.

Import

import { Link } from 'theme-ui'

Usage

<Link href="/about">About</Link>

Props

href
string
required
The URL to link to.
<Link href="/page">Internal Link</Link>
<Link href="https://example.com">External Link</Link>
variant
string
default:"'styles.a'"
Link variant from theme.links. By default uses theme.styles.a.
<Link variant="nav">Nav Link</Link>
<Link variant="button">Button-styled Link</Link>
sx
ThemeUIStyleObject
Theme-aware styles for custom link appearance.
<Link
  href="/page"
  sx={{
    color: 'primary',
    textDecoration: 'none',
    '&:hover': {
      textDecoration: 'underline',
    },
  }}
>
  Custom Link
</Link>
target
string
HTML target attribute. Use _blank for new tab.
<Link href="https://example.com" target="_blank" rel="noopener noreferrer">
  Open in new tab
</Link>
rel
string
HTML rel attribute for link relationship.

Inherited Props

Link extends Box and accepts:
  • All standard HTML anchor attributes
  • Box spacing props (m, p, mx, my, px, py, etc.)
  • Box color props (color, bg, opacity)

Examples

<Link href="/about">About Us</Link>
<Link href="https://theme-ui.com" target="_blank" rel="noopener noreferrer">
  Theme UI Documentation
</Link>
<Link
  href="/products"
  variant="nav"
  sx={{
    fontSize: 2,
    fontWeight: 'bold',
    textDecoration: 'none',
  }}
>
  Products
</Link>
<Link
  href="/signup"
  sx={{
    display: 'inline-block',
    px: 4,
    py: 2,
    bg: 'primary',
    color: 'white',
    textDecoration: 'none',
    borderRadius: 4,
    '&:hover': {
      bg: 'secondary',
    },
  }}
>
  Sign Up
</Link>
<Link
  href="/download"
  sx={{
    display: 'inline-flex',
    alignItems: 'center',
    gap: 2,
  }}
>
  Download
  <svg>...</svg>
</Link>
<Link href="/info" color="primary">
  More Info
</Link>

Underlined on Hover

<Link
  href="/page"
  sx={{
    textDecoration: 'none',
    '&:hover': {
      textDecoration: 'underline',
    },
  }}
>
  Hover Me
</Link>
<Link
  href="/current"
  sx={{
    color: 'text',
    '&[aria-current="page"]': {
      color: 'primary',
      fontWeight: 'bold',
    },
  }}
>
  Current Page
</Link>

Build docs developers (and LLMs) love