Text link
A link inside a sentence. It is text: it takes the sentence's size and breaks across lines with it.
Agents reach a tool through a gateway.
<p> Agents reach a tool through <TextLink href="/gateways">a gateway</TextLink>.</p>Installation
import { TextLink } from "@catalog-dashboard/components";In a paragraph
The link takes the size, weight and line height of the sentence it is in, and breaks across lines where the sentence does.
Agents and people cannot reach the three tools, two models and one pool that no gateway reaches until you attach them.
<p className="w-80 text-body-2 text-neutral-fg-secondary"> Agents and people cannot reach <TextLink href="#resources">the three tools, two models and one pool that no gateway reaches</TextLink> until you attach them.</p>Styles
A style is one choice, color. Primary, the link purple, is the link in plain text, with no underline. Every other value is underlined, in its color's paragraph text and its title text under the pointer: on gray or colored text, color alone cannot mark a link. primary-underline is the purple one underlined, for a purple paragraph.
primaryAgents reach a tool through a gateway.
primary-underlineAgents reach a tool through a gateway.
neutralAgents reach a tool through a gateway.
successAgents reach a tool through a gateway.
warningAgents reach a tool through a gateway.
errorAgents reach a tool through a gateway.
infoAgents reach a tool through a gateway.
fuchsiaAgents reach a tool through a gateway.
<TextLink href="/gateways" color="primary">a gateway</TextLink><TextLink href="/gateways" color="primary-underline">a gateway</TextLink><TextLink href="/gateways" color="neutral">a gateway</TextLink><TextLink href="/gateways" color="success">a gateway</TextLink><TextLink href="/gateways" color="warning">a gateway</TextLink><TextLink href="/gateways" color="error">a gateway</TextLink><TextLink href="/gateways" color="info">a gateway</TextLink><TextLink href="/gateways" color="fuchsia">a gateway</TextLink>With the app's link
render makes it another element, so a link to a page of the product is the app's own: in the dashboard, ScopedLink; here, Next's Link.
A standalone action is the Button's link.
<p className="w-80 text-body-2 text-neutral-fg-secondary"> A standalone action is <TextLink render={<Link href="/components/button" />}>the Button's link</TextLink>.</p>In an Alert
An Alert's paragraph is colored already, so color cannot mark a link there: the links inside it are underlined, and keep the paragraph's color. Under the pointer they take the title's. The Alert sets that once, for every link it holds: a link in it needs no style of its own. One given a style keeps it.
<Alert color="warning" title="Not attached to a gateway"> Agents and people cannot reach <TextLink href="#resources">3 tools</TextLink> until you attach them.</Alert>Beside the Button's link
The same words, in the same 320px sentence. The Button's link is one block that cannot break, so it runs past the edge; its size sets its own type; it carries an icon and a press; its words cannot be selected. It is for an action that stands alone.
Agents and people cannot reach until you attach them.
Agents and people cannot reach the three tools, two models and one pool that no gateway reaches until you attach them.
{/* The Button's link, inside a sentence: do not. */}<p className="w-80 text-body-2 text-neutral-fg-secondary"> Agents and people cannot reach <Button color="primary" emphasis="link" size="sm">the three tools, two models and one pool that no gateway reaches</Button> until you attach them.</p> <p className="w-80 text-body-2 text-neutral-fg-secondary"> Agents and people cannot reach <TextLink href="#resources">the three tools, two models and one pool that no gateway reaches</TextLink> until you attach them.</p>In the dashboard
Links inside sentences in the dashboard use it: the forms' gray sentences and descriptions (neutral), the billing and contact links (primary), and the links the dashboard renders from Markdown. Some links in sentences are still styled by hand (the text-link class), and move to this component later. A Field's description underlines the links inside it by itself.
Accessibility
A TextLink is the HTML <a> element: the Tab key reaches it, Enter follows it, and a screen reader reads it as a link, by its words. Its focus ring follows it onto each line it breaks across.
Primary is told from its sentence by its color. Every other style takes its sentence's color, so its underline tells it, as in an Alert.
API Reference
Besides these, the props of an <a> (target, rel…).
| Prop | Type | Default | Description |
|---|---|---|---|
color | "neutral" | "primary" | "primary-underline" | "success" | "warning" | "error" | "info" | "fuchsia" | — | Its style. Primary is the link purple, with no underline; every other value is underlined, in its color's paragraph text; primary-underline is the purple one underlined. Unset, what holds it decides: primary in plain text, the Alert's own in an Alert. |
href | string | — | Where a plain link goes. A link to a page of the product takes render instead. |
target | string | — | "_blank" opens it in a new tab; give it rel="noreferrer" too. |
render | ReactElement | — | Another element in its place: the app's own link. |
children | ReactNode | — | The link's words. |
Rules
Written down
Inside a sentence, a TextLink; alone, the Button's link
A link inside a sentence is a TextLink. A link that stands alone as an action, beside or under text, is the Button's link (emphasis="link").
From ds/README.md (Text link) and ds/components/text-link.tsx.
Primary is marked by color; every other style by its underline
Primary is the link color, and the Button's primary link's color under the pointer, with no underline. Every other color takes its paragraph's text color, so it is always underlined.
From ds/README.md (Text link) and ds/components/text-link.tsx.
In an Alert, underlined in the paragraph's color
Under the pointer it takes the title's color. The Alert sets it for every link inside it, so a link there needs no style; one given a style keeps it.
From ds/README.md (Text link) and ds/tokens/text-link.css.