Components / Controls
Link
An inline text link that takes the user somewhere. For an action that doesn't navigate, use Button.
When to useLink to "When to use"
- Links inside sentences, help text and footers.
externalfor pages outside your product.
Use something else when:
UsageLink to "Usage"
tsx
import { Link } from "@arshad-shah/cynosure";
<Link href="/docs">Read the docs</Link>
<Link href="https://example.com" external>Example</Link>
<Link href="mailto:hello@example.com" tone="neutral" size="sm">Email us</Link>External linksLink to "External links"
external opens a new tab with a safe rel, adds an external icon and announces "(opens in new tab)" to screen readers. Change that text with labels.external.
Tone and sizeLink to "Tone and size"
tone defaults to accent; text uses each tone's readable text colour. size defaults to inherit, so the link matches the surrounding text; sm, md and lg set a fixed size.
PropsLink to "Props"
| Prop | What it does | Type | Default |
|---|---|---|---|
hrefRequired | Where the link goes. | string | |
childrenRequired | The link text. | ReactNode | |
tone | Colour of the text. Default "accent". | Tone | "accent" |
size | Text size; inherit follows the surrounding text. Default "inherit". | Size | "inherit" | "inherit" |
external | Opens in a new tab with a safe rel, an external icon and announced text. | boolean | |
underline | When the underline shows: always (default), hover (on hover and focus) or none. Leave it on in running text, where the underline is what tells a link from the words around it; take it off only where the place says it is a link (a navigation bar, a footer's columns, a card title). | "none" | "always" | "hover" | |
aria-current | Marks the link as the current item of a set, e.g. "page" for the page being shown in a navigation bar. | boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | |
onClick | Called when the link is activated. | MouseEventHandler<HTMLAnchorElement> | |
labels | Replace the built-in English text: external is read out after a link that opens in a new tab. | { external?: string; } | |
className | Added to the root element, for layout. | string | |
style | Layout only. | CSSProperties |
Generated from the type definitions in @arshad-shah/cynosure 0.5.0.
Behaviour and accessibilityLink to "Behaviour and accessibility"
| Input | Result |
|---|---|
| Click, Enter | Follows the link, or calls onClick |
| Tab | Focus with a visible ring |
- Safe schemes:
hrefmay be relative,http(s),mailtoortel. Other schemes are not linked. - Ref: the ref points at the anchor.
ThemingLink to "Theming"
Tokens: --cy-link-underline-offset and --cy-link-underline-thickness.
ts
createTheme({ components: { link: { underlineThickness: "2px" } } });RelatedLink to "Related"
These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.