Skip to content

Link

An accessible anchor component with variant styles, external link support, and icon slots. Links inherit the surrounding text size.

Import

import { Link } from "@hyzer-labs/ui"

Demo

<Link href="/docs">Default link</Link>

Props

NameTypeDefaultNote
hrefstringRequired.
externalbooleanfalse
externalIconbooleantrueAuto external glyph; iconEnd replaces it, false suppresses it.
variant'default' | 'subtle' | 'nav''default'
ariaCurrent'page' | 'step' | 'true'
ariaLabelstring
onclick(e: MouseEvent) => void
classstringMerged after the hz-link class.
childrenSnippet
iconStartSnippet
iconEndSnippet

Theme hooks

What this component promises your CSS. The reference theme styles exactly these — from @layer hz-theme, so your unlayered rules win. See Styling Components for the how.

Root class: .hz-link

Data attributes

HookValuesStyles
data-variant'default' | 'subtle' | 'nav'Its own union, not the shared Variant. subtle inherits colour; nav is quiet until hover or aria-current. No size hook by design — a link inherits its surrounding text size.
[aria-current]'page' | 'step' | 'true'Load-bearing for styling, not just semantics: the active nav-link rule is [data-variant="nav"][aria-current].
data-externalpresent on external linksAccompanies target="_blank" and the visually-hidden "opens in new tab" hint. The reference theme styles the glyph instead, so this one is yours.

Part classes

HookValuesStyles
.hz-link-external-iconchild elementThe auto-rendered external glyph. Absent when you supply your own iconEnd.

Accessibility

External links automatically add target="_blank", rel="noopener noreferrer", a decorative external glyph, and a visually-hidden "(opens in new tab)" string. ariaCurrent sets aria-current on the anchor for nav links.

References: APG Link pattern · MDN: <a>