Skip to main content

Link

Link is a styled anchor element with variants for different use cases.

Import

import { Link } from "@tosui/react";

Basic Usage

<Link href="/docs">Documentation</Link>

Variants

<VStack gap={4} align="flex-start">
<Link variant="default" href="#">Default (underline on hover)</Link>
<Link variant="underline" href="#">Underline (always underlined)</Link>
<Link variant="subtle" href="#">Subtle (inherits color)</Link>
</VStack>

Use external for links that open in a new tab. This automatically adds target="_blank" and rel="noopener noreferrer".

<Link href="https://github.com" external>
GitHub (opens in new tab)
</Link>
<Box>
Read our <Link href="#">documentation</Link> for more information,
or check out the <Link href="#">getting started guide</Link>.
</Box>

With Router Libraries

Link is polymorphic and works with router libraries like React Router or Next.js.

// React Router
import { Link as RouterLink } from "react-router-dom";

<Link as={RouterLink} to="/about">
About
</Link>

// Next.js
import NextLink from "next/link";

<Link as={NextLink} href="/about">
About
</Link>
<VStack as="nav" gap={2} align="flex-start">
<Link href="#">Home</Link>
<Link href="#">Products</Link>
<Link href="#">About</Link>
<Link href="#">Contact</Link>
</VStack>

Props Reference

PropTypeDefaultDescription
variant"default" | "underline" | "subtle""default"Visual variant
externalbooleanfalseOpen in new tab
hrefstring-Link destination
asElementType"a"HTML element or router component

Link also accepts all Box styling props.

TypeScript

import { Link, type LinkVariant, type LinkProps, type LinkOwnProps } from "@tosui/react";