component
Link
A link inside text. Green and underlined, or quiet in the text's own colour.
Accent · DefaultQuiet · DefaultHover, press or tab to one to see the other 6 states.
import { Link } from 'rost/components/link/Link'
<p>Read the <Link href="/docs/contract/">contract guide</Link> first.</p>
<Link href="https://github.com/Runceanu/rost" tone="quiet" external>GitHub</Link> src/components/link/Link.tsx
import type { AnchorHTMLAttributes, ReactNode } from 'react'
import './link.css'
export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
readonly href: string
/** `accent` in a sentence; `quiet` where every word is a link. */
readonly tone?: 'accent' | 'quiet'
/** Opens in a new tab, and says so to screen readers. */
readonly external?: boolean
readonly children?: ReactNode
}
const b = 'rost-link'
/** A link inside text. Built from contracts/link.contract.yaml. */
export function Link({ tone = 'accent', external = false, className, children, ...rest }: LinkProps) {
const ext = external ? { target: '_blank', rel: 'noreferrer' } : {}
return (
<a className={[b, `${b}--tone-${tone}`, className].filter(Boolean).join(' ')} {...ext} {...rest}>
{children}
{external && <span className={`${b}__label`}> (opens in a new tab)</span>}
</a>
)
}
The source for everything on this page: contracts/link.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: link
name: Link
kind: component
status: review
summary: A link inside text. Green and underlined, or quiet in the text's own colour.
category: navigation
related: [ button, text ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "705:81"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=705-81
extractedAt: "2026-11-04"
extractedBy: hand
frozenAt: "2026-11-04"
props:
href: { type: string, required: true }
tone:
type: enum
values: [ accent, quiet ]
default: accent
notes: "`accent` for a link in a sentence. `quiet` where links are all there is, like a footer or a row of sources, and green everywhere would be noise."
external:
type: boolean
default: false
notes: Opens in a new tab, and says so to screen readers.
children: { type: slot, notes: "The words. Say where it goes, never \"here\"." }
states: [ Default, Hover, Pressed, Focus ]
elements:
root:
notes: An `<a>`. It sits in a line of text, so it takes the text's size and weight.
styles:
color: { token: non-interactive/foreground/positive/base, value: "#00d669", notes: "#0e7118 in light, so it keeps AA on the light page." }
text-decoration-line: { value: underline }
text-decoration-thickness: { token: spacing/outline/small, value: 1px }
text-underline-offset: { value: 0.2em, untokenised: "Follows the text's size, so it's in em, not a space token." }
text-decoration-color: { value: currentColor, assert: false }
border-radius: { token: spacing/radius/xsmall, value: 4px, notes: Only shows with the focus ring. }
transition-property: { value: "color, text-decoration-color", assert: false }
transition-duration: { token: motion/duration/fast, value: 150ms }
transition-timing-function: { token: motion/easing/standard, value: ease }
label:
notes: The visually hidden "(opens in a new tab)" of an external link.
styles:
position: { value: absolute, assert: false }
width: { value: 1px, assert: false }
height: { value: 1px, assert: false }
overflow: { value: hidden, assert: false }
clip-path: { value: inset(50%), assert: false }
white-space: { value: nowrap, assert: false }
variants:
- when: { tone: quiet, state: Default }
figmaNode: "705:65"
elements:
root:
color: { value: inherit, assert: false, notes: "The text's own colour." }
text-decoration-color: { value: transparent, assert: false, notes: The underline comes on hover. }
- when: { tone: accent, state: Hover }
figmaNode: "705:67"
elements:
root:
color: { token: non-interactive/foreground/positive/dark, value: "#b6ffda" }
- when: { tone: quiet, state: Hover }
figmaNode: "705:69"
elements:
root:
color: { token: non-interactive/foreground/primary, value: "#ededed" }
text-decoration-color: { value: currentColor, assert: false }
- when: { tone: accent, state: Pressed }
figmaNode: "705:71"
elements:
root:
color: { token: non-interactive/foreground/positive/dark, value: "#b6ffda", notes: "Hover's colour. Pressed used to fade to 72%, which took the light theme to 3.5:1 on white." }
- when: { tone: quiet, state: Pressed }
figmaNode: "705:73"
elements:
root:
color: { token: non-interactive/foreground/primary, value: "#ededed" }
text-decoration-color: { value: currentColor, assert: false }
- when: { state: Focus }
elements:
root:
outline-style: { value: solid }
outline-width: { token: spacing/outline/medium, value: 2px }
outline-color: { token: actions/primary/focus/focus-ring, value: "#b6ffda" }
outline-offset: { value: 2px, notes: "Clear of the letters, the same 2px every focus ring here uses." }
guidance:
status: proposed
use:
- title: In a sentence
text: Pointing somewhere from inside a sentence, a note or a table cell.
show: tone=accent, state=Default
- title: A row of sources
text: "`quiet` for a footer or a line of links under a section, where every word is a link."
show: tone=quiet, state=Default
avoid:
- title: Doing something
text: Starting an action, like saving or sending. That's **Button**.
- title: Standing alone
text: A link on its own line that's the main way on. A **Button** with `href` reads as the next step, a Link doesn't.
behaviour: |-
The underline is always there on `accent`, so a link never relies on colour alone. `quiet` takes the text's colour and shows the underline on hover. An external link opens a new tab and gets a hidden "(opens in a new tab)". I didn't add an arrow icon: in running text it was more noise than help.
accessibility:
element: an `<a href>`. Without an href it isn't a link, so don't render one.
name: the words inside. "here" or "more" tell a screen reader nothing out of context.
colour: "`accent` is `non-interactive/foreground/positive/base`: 6:1 on the light page and 5.3:1 on the light card, 9:1 or more in dark."
content: Say where it goes, in a few words. Sentence case.
Install
npx github:Runceanu/rost add link It lands in src/rost/link/, with what it needs and its contract. Install has the rest.
When to use
In a sentence
Pointing somewhere from inside a sentence, a note or a table cell.
A row of sources
quietfor a footer or a line of links under a section, where every word is a link.
When not to use
Doing something
Starting an action, like saving or sending. That's Button.
Standing alone
A link on its own line that's the main way on. A Button with
hrefreads as the next step, a Link doesn't.
Behaviour
The underline is always there on accent, so a link never relies on colour alone. quiet takes the text's colour and shows the underline on hover. An external link opens a new tab and gets a hidden "(opens in a new tab)". I didn't add an arrow icon: in running text it was more noise than help.
Accessibility
- Element
an
<a href>. Without an href it isn't a link, so don't render one. - Name
the words inside. "here" or "more" tell a screen reader nothing out of context.
- Colour
accentisnon-interactive/foreground/positive/base: 6:1 on the light page and 5.3:1 on the light card, 9:1 or more in dark.
Content
Say where it goes, in a few words. Sentence case.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
href | string | | |
tone | enum | accent · quiet | accent |
external | boolean | | false |
children | slot | | |
States: Default, Hover, Pressed, Focus.
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
color#00d669non-interactive/foreground/positive/base -
text-decoration-lineunderlineno token yet -
text-decoration-thickness1pxspacing/outline/small -
text-underline-offset0.2emon purpose: Follows the text's size, so it's in em, not a space token. -
border-radius4pxspacing/radius/xsmall -
transition-duration150msmotion/duration/fast -
transition-timing-functioneasemotion/easing/standard
text-decoration-colorcurrentColor · transition-propertycolor, text-decoration-color
label
positionabsolute · width1px · height1px · overflowhidden · clip-pathinset(50%) · white-spacenowrap
Changes by variant
6 variants. Each table is what one thing changes with: a column per state, a row per property. Where every row starts with the same token path, it's written once, under the property.
Follows state
Quiet
| Property | Default | Hover | Pressed |
|---|---|---|---|
root.text-decoration-color | transparent | currentColor | currentColor |
Follows tone and state
Quiet
| Property | Default | Hover | Pressed |
|---|---|---|---|
root.colornon-interactive/foreground/… | inherit | primary #ededed | primary #ededed |
Accent
| Property | Default | Hover | Pressed |
|---|---|---|---|
root.colornon-interactive/foreground/positive/… | · | dark #b6ffda | dark #b6ffda |
Only in some variants
These don't change: they're just set in some variants and not others.
Focus
-
root.outline-color#b6ffdaactions/primary/focus/focus-ring -
root.outline-offset2pxno token yet -
root.outline-stylesolidno token yet -
root.outline-width2pxspacing/outline/medium