Link
Text that goes to another page or resource, with an underline, a new-tab warning and a current-page state.
import { Link } from '@slotted/react/link';import { Text } from '@slotted/react/typography';export default function LinkBasic() { return ( <Text> Payment is due 30 days after the invoice date. Read the{' '} <Link href="#terms">terms of service</Link> before you confirm the order. </Text> );}Installation
The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.
pnpm add @slotted/react @slotted/theme @slotted/themesimport { Link, LinkDefaultsProvider } from '@slotted/react';Link or button
A link goes somewhere: it renders an anchor with an href, so the link role, Enter, the context menu, the middle click and every modified click come from the platform. An action that runs a handler and leaves the page where it is, such as sending an email again, is a Button, and inline sets it in the text around it. Space does not activate a link, and Link does not add it. For a navigation that wants the surface of a button, use ButtonLink in React and slButtonLink in Angular.
import { Button } from '@slotted/react/button';import { Link } from '@slotted/react/link';import { Text } from '@slotted/react/typography';export default function LinkAction() { return ( <Text> Invoice INV-2026-08-0041 was sent to the buyer on September 3.{' '} <Link href="#invoice">View the invoice</Link> or <Button inline>send it again</Button>. </Text> );}Underline
underline sets when the underline is drawn. always, the default, is the only value that suits a link inside a sentence, because color alone does not tell a link from the text beside it. hover draws the underline on hover and on keyboard focus, and none never draws it. Use hover and none where the position already says the text is a link, such as a navigation row or a table cell. Under forced colors the underline returns whatever the value is.
import { Inline } from '@slotted/react/inline';import { Link } from '@slotted/react/link';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';export default function LinkUnderline() { return ( <Stack gap={3}> <Inline gap={3}> <Text size="sm" tone="muted"> always </Text> <Link href="#register">Invoice register</Link> </Inline> <Inline gap={3}> <Text size="sm" tone="muted"> hover </Text> <Link href="#payments" underline="hover"> Payment runs </Link> </Inline> <Inline gap={3}> <Text size="sm" tone="muted"> none </Text> <Link href="#suppliers" underline="none"> Supplier directory </Link> </Inline> </Stack> );}Variants
variant sets how the link is painted. accent, the default, uses the accent color. neutral takes the color of the text around it, so it belongs where nothing else on the line could be mistaken for it, such as a cell, a title or a row, and never inside a sentence. inverse uses the inverse text color, for a link on a solid surface.
Your trial ends in three days. Choose a plan
import { Alert, AlertContent, AlertDescription } from '@slotted/react/alert';import { Inline } from '@slotted/react/inline';import { Link } from '@slotted/react/link';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';export default function LinkVariants() { return ( <Stack gap={4}> <Text> Review the <Link href="#history">payment history</Link> before the due date. </Text> <Inline gap={3}> <Text size="sm" tone="muted"> Invoice </Text> <Link href="#invoice" underline="hover" variant="neutral"> INV-2026-08-0041 </Link> </Inline> <Alert tone="accent" variant="solid"> <AlertContent> <AlertDescription> Your trial ends in three days.{' '} <Link href="#plans" variant="inverse"> Choose a plan </Link> </AlertDescription> </AlertContent> </Alert> </Stack> );}Sizes
size sets the text to xs, sm or md: 12, 13 or 14 pixels on the type scale. Without it, a link takes the size its action slot states, or else the size of the text around it.
import { Inline } from '@slotted/react/inline';import { Link } from '@slotted/react/link';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';export default function LinkSizes() { return ( <Stack gap={3}> <Inline align="baseline" gap={4}> <Link href="#orders" size="xs"> Orders </Link> <Link href="#shipments" size="sm"> Shipments </Link> <Link href="#returns" size="md"> Returns </Link> </Inline> <Text size="lg"> Without a size, a link takes the text around it:{' '} <Link href="#forecast">open the demand forecast</Link>. </Text> </Stack> );}States
A link that has no destination yet is disabled. It renders no href, which stops a middle click as well as a left one, and it keeps role="link", aria-disabled and its place in the tab sequence, so a keyboard reader can still find it. Hover and press change the color and the underline. visited opts in to the visited color, which the browser applies once the destination is in its history.
import { Link } from '@slotted/react/link';import { Stack } from '@slotted/react/stack';export default function LinkStates() { return ( <Stack gap={3}> <Link href="#order-4821">Open order 4821</Link> <Link href="#order-4820" visited> Order 4820, in the visited color once followed </Link> <Link disabled href="#order-4822"> Order 4822, available once it ships </Link> </Stack> );}Leaving the application
external opens the destination in a new tab and states it three ways: rel="noopener noreferrer", a marker for the eye, and the words “(opens in a new tab)” appended to the accessible name. The three follow the resolved target, so a target="_blank" you write yourself is warned about in the same way, and target="_self" beside external withdraws the warning. rel and target that you write are kept. messages replaces the wording of the warning: pass externalHint.
import { Link } from '@slotted/react/link';import { Stack } from '@slotted/react/stack';export default function LinkExternal() { return ( <Stack gap={3}> <Link external href="https://example.com/carriers/northwind-freight"> Carrier tracking page </Link> <Link href="https://example.com/status" target="_blank"> Carrier service status </Link> <Link external href="https://example.com/customs/guide" messages={{ externalHint: '(opens in a new window)' }} > Customs documentation guide </Link> </Stack> );}Current page
A link marks the page you are on through aria-current, the attribute a router already writes. The link takes the body text color. Its underline and its weight do not change, so the row does not shift. Link has no prop for it. In Angular, routerLinkActive with ariaCurrentWhenActive writes the attribute on the anchor.
import { Inline } from '@slotted/react/inline';import { Link } from '@slotted/react/link';export default function LinkCurrent() { return ( <nav aria-label="Workspace"> <Inline gap={4}> <Link aria-current="page" href="#orders" underline="hover"> Orders </Link> <Link href="#shipments" underline="hover"> Shipments </Link> <Link href="#returns" underline="hover"> Returns </Link> <Link href="#suppliers" underline="hover"> Suppliers </Link> </Inline> </nav> );}Your own router link
In React, render substitutes the element and hands it the destination and every data attribute, so a router’s own link component keeps both. In Angular, slLink is an attribute on your own anchor, so routerLink and routerLinkActive sit on the same element. The example handles the click itself, which is what a router link does: the view changes and the page does not reload.
import { Inline } from '@slotted/react/inline';import { Link } from '@slotted/react/link';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';import { useState } from 'react';import type { MouseEvent, ReactNode } from 'react';const VIEWS = [ { href: '#orders', label: 'Orders' }, { href: '#shipments', label: 'Shipments' }, { href: '#returns', label: 'Returns' },] as const;interface RouterLinkProps { children: ReactNode; current: boolean; href: string; onNavigate: (href: string) => void;}export default function LinkRouter() { const [path, setPath] = useState<string>(VIEWS[0].href); const label = VIEWS.find((view) => view.href === path)?.label; return ( <Stack gap={3}> <nav aria-label="Workspace"> <Inline gap={4}> {VIEWS.map((view) => ( <RouterLink current={view.href === path} href={view.href} key={view.href} onNavigate={setPath} > {view.label} </RouterLink> ))} </Inline> </nav> <Text size="sm" tone="muted"> Showing {label}. </Text> </Stack> );}function RouterLink({ children, current, href, onNavigate }: RouterLinkProps) { function handleClick(event: MouseEvent<HTMLAnchorElement>) { event.preventDefault(); onNavigate(href); } return ( <Link aria-current={current ? 'page' : undefined} href={href} render={(props) => <a {...props} onClick={handleClick} />} underline="hover" > {children} </Link> );}Defaults for the application
LinkDefaultsProvider in React and provideLinkDefaults in Angular set underline, variant and visited once for everything below them. A link that states a value of its own keeps it, as the last link here keeps its accent underline.
import { Link, LinkDefaultsProvider } from '@slotted/react/link';import { Stack } from '@slotted/react/stack';export default function LinkApplicationDefaults() { return ( <LinkDefaultsProvider underline="hover" variant="neutral"> <Stack gap={2}> <Link href="#inv-0041">INV-2026-08-0041</Link> <Link href="#inv-0042">INV-2026-08-0042</Link> <Link href="#inv-0043">INV-2026-08-0043</Link> <Link href="#register" underline="always" variant="accent"> Open the invoice register </Link> </Stack> </LinkDefaultsProvider> );}Accessibility
- The rendered element is a plain anchor with an href, so the link role, Enter, the context menu and every modified click come from the platform. Space does not activate a link, and nothing here makes it. An action inside a line that runs a handler and goes nowhere is a Button with inline, not a Link without an href.
- underline="always" is the default because color alone does not distinguish a link: the accent text color clears 4.5:1 against the surface and not 3:1 against the body text beside it.
- variant="neutral" takes the color of the text around it, so it belongs where nothing on the line could be mistaken for it — a cell, a title, a row — and never inside a sentence.
- Whatever the underline axis says, the underline returns under forced-colors, where the palette flattens the color contrast a bare link relies on.
- A new browsing context is announced in the accessible name and marked with a glyph, and both follow the resolved target: a target="_blank" you write is warned about exactly like external.
- external also sets rel="noopener noreferrer"; a rel or target you pass is kept instead of rewritten.
- A disabled link renders no href, which is what stops a middle click as well as a left one, and keeps role="link", aria-disabled and its place in the tab sequence so the state can be discovered.
- The current page is painted from aria-current, the attribute a router already writes; Link adds no prop for it.
API
Link
Props
underline'always' | 'hover' | 'none'Defaultalways- When the underline is drawn.
variant'accent' | 'neutral' | 'inverse'Defaultaccent- The accent color, the color of the surrounding text, or the color for a solid surface.
size'xs' | 'sm' | 'md'- The text size: 12, 13 or 14 pixels on the type scale. Unset, the link takes the size its action slot states — a stat card’s action, a section’s or a chart’s actions state sm — or else its parent’s.
externalbooleanDefaultfalse- Opens a new tab and warns that it does.
messagesPartial<LinkMessages>- Words laid over the language in force: the wording of that warning (externalHint).
disabledbooleanDefaultfalse- Withholds the destination, keeps the role, the state and the tab stop.
visitedbooleanDefaultfalse- Paints a destination the reader already followed.
hrefstring- The destination, and every other anchor attribute — target, rel, download, hreflang — reaches the element unchanged.
Composition
render(props: LinkRootProps) => ReactNode- Substitutes the rendered element. The destination and every data attribute are handed to it, so a router link keeps both.
refRef<HTMLAnchorElement>- Reaches the anchor, and focus() with it.
onClick, onAuxClick, onKeyDownEventHandler- Composed rather than replaced. While disabled, Link refuses the event first and the handler is not called.
LinkDefaultsProviderunderline | variant | visited- On ApplicationSets those three once for everything below it. A prop on the link still wins.
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | a | Yes | The link itself. Carries data-ui="link", the axes as data attributes, and every native anchor attribute you pass. |
external-icon | span | No | The marker a new tab earns: the external Glyph inside a directional icon box, sized to the text and hidden from assistive technology. Rendered only when the resolved target is _blank. |
external-hint | span | No | The same warning in words, clipped from view and appended to the accessible name. Rendered with the visually-hidden family. |
Theming
Each token is a CSS custom property: set it in a theme, or on any element to retune every link inside it.
Link tokens
| Token | Default |
|---|---|
--slotted-link-color | var(--slotted-tone-accent-text, LinkText) |
--slotted-link-color-active | color-mix(in oklab, var(--_rest) 35%, var(--_strong)) |
--slotted-link-color-current | var(--slotted-text, CanvasText) |
--slotted-link-color-disabled | var(--slotted-disabled-foreground, GrayText) |
--slotted-link-color-hover | color-mix(in oklab, var(--_rest) 65%, var(--_strong)) |
--slotted-link-color-visited | color-mix(in oklab, var(--_rest) 40%, var(--slotted-text-muted, GrayText)) |
--slotted-link-external-icon-gap | 0.15em |
--slotted-link-external-icon-size | 1em |
--slotted-link-focus-ring-offset | 1px |
--slotted-link-font-size | inherit |
--slotted-link-radius | var(--slotted-control-radius, 4px) |
--slotted-link-underline-color | color-mix(in oklab, currentColor 55%, transparent) |
--slotted-link-underline-offset | 0.15em |
--slotted-link-underline-thickness | from-font |
Theme tokens it reads
| Token | Default |
|---|---|
--slotted-control-radius | var(--slotted-radius-sm) |
--slotted-disabled-foreground | Set per scheme by the theme |
--slotted-duration-short | 120ms |
--slotted-easing-standard | cubic-bezier(0.2, 0, 0, 1) |
--slotted-focus-ring-color | Set per scheme by the theme |
--slotted-focus-ring-width | var(--slotted-border-width-thick) |
--slotted-font-size-md | 0.875rem |
--slotted-font-size-sm | 0.8125rem |
--slotted-font-size-xs | 0.75rem |
--slotted-text | Set per scheme by the theme |
--slotted-text-inverse | Set per scheme by the theme |
--slotted-text-muted | Set per scheme by the theme |
--slotted-tone-accent-text | Set per scheme by the theme |