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-developer/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>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; the link takes no prop.
<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
New, not used by a screen yet. A link in a sentence is styled by hand today, 93 times in 66 files, most as the link color with an underline under the pointer. A Field's description styles the links inside it by itself, underlined. Moving them to this component is a later change.
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.
In plain text it is told from the sentence by its color alone. In an Alert, where the sentence is colored too, the underline tells it.
API Reference
Besides these, the props of an <a> (target, rel…).
| Prop | Type | Default | Description |
|---|---|---|---|
href | string | — | Where a plain link goes. |
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.
Marked by color, not by an underline
In plain text it is the link color, and the Button's primary link's color under the pointer. It is not underlined.
From ds/README.md (Text link) and ds/tokens/text-link.css.
In an Alert, underlined in the paragraph's color
Under the pointer it takes the title's color. What holds the link sets its tokens for every link inside it. The link itself takes no prop for it.
From ds/README.md (Text link) and ds/tokens/text-link.css.