TextLink
The PR mock's text link (a: raspberry, 600, no underline until hover): "All", "See all", "Change", "Gift stock →". An <a> with href (through safeHref), a <button type="button"> without it, so an action that opens a drawer or a dialog is a real button. arrow adds the trailing →, tone="ink" the bold ink look, size="sm" 13px. It keeps a visible focus ring, and a 44px hit area on touch tiers (1024px and under) without changing its look.
import { TextLink } from '@ergasti/bricks';Examples
Button or link
Without href it is a button (an action that opens a drawer or a list); with href an anchor, its URL checked by safeHref. arrow adds the trailing →.
Code
import { TextLink } from '@ergasti/bricks';
function Links() {
return (
<div style={{ display: 'flex', gap: 20, alignItems: 'center', flexWrap: 'wrap' }}>
<TextLink onClick={() => {}}>See all</TextLink>
<TextLink href="#gifts" arrow>Gift stock</TextLink>
<TextLink tone="ink" onClick={() => {}}>Winter top 10</TextLink>
<TextLink disabled>Change</TextLink>
</div>
);
}In a card head
A small link as the card's actions ("All", "Change"); give it an aria-label when its words alone do not say where it goes.
Code
import { Card, TextLink } from '@ergasti/bricks';
function InCard() {
return (
<div style={{ maxWidth: 380 }}>
<Card title="PR owner" actions={<TextLink onClick={() => {}} aria-label="Change Glow Lab's PR owner">Change</TextLink>}>
<p style={{ margin: 0 }}>Mona (you)</p>
</Card>
</div>
);
}Arabic
The arrow points the reading way.
Code
import { TextLink } from '@ergasti/bricks';
function Arabic() {
return <TextLink href="#gifts" arrow>مخزون الهدايا</TextLink>;
}Props
Prop
Type
Design guidance
How the BRICKS design system uses TextLink. Written in docs/content/components/TextLink.md; the props above are read from the code, which wins where the two disagree.
The PR Portal's raspberry text link, 600 weight, underlined only on hover; use it for small "go there" or "open that" words in a card head, at the end of a note or in a row ("All", "See all", "Change", "Gift stock →").
It is the PR v3 mock's bare a style (color: var(--rasp); font-weight: 600; text-decoration: none, underline on hover). It renders a real <a> when given href (the URL goes through safeHref, so a javascript: URL renders no href) and a <button type="button"> otherwise, so an action that opens a drawer or dialog is a real button. Before 0.7 screens and PR blocks used ad-hoc link buttons (.kit-pr-link, .kit-pr-link--ink, or plain <a> tags); use TextLink instead so focus ring, disabled look and touch hit area come with it.
Anatomy
- Element:
<a class="kit-textlink">withhref, else<button type="button" class="kit-textlink">; no padding, border or background,text-align: start,align-self: flex-startin a flex column. - Words:
children. - Arrow (optional):
.kit-textlink-arrow, a "→" 0.3em after the words,aria-hidden, mirrored in RTL.
Variants
| Prop value | Look | When to use |
|---|---|---|
tone="rasp" (default) | Raspberry, 600 | Every navigation or "open" link: "All", "See all", "Change", "Gift stock →". |
tone="ink" | Ink, 700 | A name in a list that opens it (a challenge's name). |
size="inherit" (default) | The surrounding size | Inside a sentence or a Note. |
size="sm" | 13px | In a card head's actions or a section head. |
arrow | Trailing → | A link that leaves the current page ("Gift stock →"). |
href | <a> | It navigates (a URL, a router path). target="_blank" adds rel="noopener noreferrer" unless rel is given. |
no href | <button type="button"> | It acts in place: opens a drawer, a dialog, a list. |
States
| State | Trigger |
|---|---|
| Hover | Underline. |
| Focus-visible | No outline; --focus-ring box shadow on a --radius-xs corner. |
| Disabled | disabled (button only): --ink-3, default cursor, no underline, does not act. |
| Touch (≤1024px) | A transparent 44px hit area (--min-touch-target) around it; the look does not change. |
Usage
// PR Portal › Home › My brands: "All" in the card head, as a button that opens the list
import { Card, TextLink } from '@ergasti/bricks';
export function MyBrandsCard({ openBrands }: { openBrands: () => void }) {
return (
<Card title="My brands" actions={<TextLink size="sm" onClick={openBrands}>All</TextLink>}>
<p style={{ margin: 0 }}>Glow Lab, Nile Threads</p>
</Card>
);
}// PR Portal › Brand detail: "Change" the owner opens ChangeOwnerDialog; say whose owner in the accessible name
import { TextLink } from '@ergasti/bricks';
export function OwnerChange({ openDialog }: { openDialog: () => void }) {
return <TextLink onClick={openDialog} aria-label="Change Glow Lab's owner">Change</TextLink>;
}// An anchor through a client-side router, with the arrow
import { TextLink } from '@ergasti/bricks';
export function GiftStockLink({ navigate }: { navigate: (path: string) => void }) {
return (
<TextLink href="/gifts" arrow onClick={(e) => { e.preventDefault(); navigate('/gifts'); }}>
Gift stock
</TextLink>
);
}// A challenge's name in a list: the ink tone, data text with its own direction
import { TextLink } from '@ergasti/bricks';
export function ChallengeName({ name, open }: { name: string; open: () => void }) {
return <TextLink tone="ink" dir="auto" onClick={open}>{name}</TextLink>;
}Where it appears
- PR Portal › Home › My brands and Live challenges: each card's "All" (PR · Home).
- PR Portal › Brand detail › the gift stock line under Gift rules (
size="sm"), "All creators", and the owner's "Change" (PR · Brand). - PR Portal › Affiliate programs › Challenges › Brand request › the gift stock card's "Gift stock →" (PR · Brand request).
- PR Portal › Sign in ›
LoginCard's "Forgot password" (PR · Sign in).
Guidelines
Do
- Give it
hrefwhen it goes somewhere, and nohrefwhen it does something on the page. - Add
aria-labelwhen the words alone don't say what or where ("Change" → "Change Glow Lab's owner"). - Use
arrowfor links that leave the page, andsize="sm"in card heads.
Don't
- Don't use it for a page's or dialog's main action; that is a
Button(in the PR Portal, commits areink, creating/sending and destructive confirms arerasp, Cancel isdefault). - Don't style a
Button variant="ghost"or a bare<a>to look like this. - Don't put two text links side by side without words between them; use a
SegmentedorPillTabsfor a choice.
RTL and Arabic
- The arrow flips (
scaleX(-1)) and sits after the words at the inline end: "مخزون الهدايا ←". - Pass
dir="auto"when the words are data (a brand or challenge name).
Tokens
--rasp, --ink, --ink-3, --radius-xs, --focus-ring, --min-touch-target.
Accessibility
- A native
<a>or<button type="button">: Enter (and Space on the button) works; no ARIA needed. - The arrow is
aria-hidden, so "Gift stock →" is read "Gift stock". disableduses the native attribute (button only), so it leaves the tab order.- Visible focus ring; 44px hit area on touch tiers without changing the layout.
safeHrefdrops unsafe URLs;_blankgetsnoopener noreferrer.
Found in the source
- ARIA attributes set:
aria-hidden. - Its tests cover: “without href is a button that acts on click and on Enter”; “arrow adds a trailing → hidden from screen readers, so the name stays the words”; “Arabic: the arrow is mirrored by the stylesheet, not by the copy”; “the CSS: raspberry 600, a visible focus ring, and the 44px touch hit area at 1024px and under”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
Button,ButtonLink: real actions and links that must look like buttons.Note: the muted line a text link often ends.MiniRow(onOpen/href): when the whole row is the target.Term/MoneyNote: dotted words that explain instead of navigate.
See also: Card · Avatar · AvatarStack
Source
src/kit/primitives/TextLink.tsx (line 36) on GitHub.