Raft 设计系统

组件 · 操作

TextLink

Text that underlines on hover, for the quietest control on a screen, an action or a way somewhere; the bottom step of the button ladder.

稳定也叫 Link button, Text button
import { TextLink } from "@botiverse/raft-ui";
本页尚未翻译
译文完成之前,这里显示英文原文。 阅读英文版

TextLink is text that does something or goes somewhere, with no underline until the pointer is over it. It is the bottom step of the emphasis ladder, below a frameless button (Button): use it where even a frameless button would be too much weight, such as Forgot Password on a sign-in page, Sign Out under a server list, or a See All beside a section title.

text-link/compositions/preview

When to use

SituationUse
The quietest control on a screen, alone or inside a sentenceTextLink
Cancel or a minor action inside a dialog, sheet, menu, popover or cardButton variant="ghost"
Cancel or a minor action on a pageButton variant="default"
A link inside rendered message or document contentThe Markdown link, in the link blue (Markdown)

Variants

The variant follows where the link sits, not how important the action is.

VariantUse for
variant="muted" (default)A link that stands on its own: Forgot Password, Sign Out, See All. foreground-muted, 500; on hover, ink and underlined.
variant="strong"A link inside a sentence: "Don't have an account? Create One", a banner's "Manage Machines". Ink, 600; on hover, underlined in ink.

Why the position decides. On its own, a TextLink is the quietest control on the screen, so it is muted: it must not compete with the screen's text or its buttons. Inside a sentence, the same muted grey would sit lighter than the words around it and read as disabled, so there it takes the ink of body text and stands out by weight instead. Neither variant is pink, at rest or on hover: pink belongs to the one primary button.

Why the underline comes on hover. The underline is the hover signal for every piece of clickable text in raft-ui, so people learn it once (Clickable text). At rest, the weight and color above and where the link sits say it can be clicked; an underline on every quiet control would add a line under each of them on a screen that is read for hours.

States

  • Hover: the text underlines in its own color, 1.5px thick, 3px below the baseline; a muted link also turns ink.
  • Disabled: the text turns foreground-disabled and nothing changes on hover, so it no longer reads as something to press.
text-link/compositions/disabled
  • Focus: the shared focus ring (States), on a 2px radius.

Behavior

  • TextLink has no size of its own: it takes the size and line height of the text around it, so it sits on the baseline inside a sentence and cannot make the line taller. Standing alone, give its container the text size.
  • It has no box, padding or minimum height. Don't put it where it is the only thing a finger must hit on a phone; that needs a Button.

Content

  • Start with a verb, or name the place: Forgot Password, Sign Out, See All.
  • Use Title Case, like every button label (Writing).

Accessibility

TextLink renders a native button type="button". For a way somewhere, render a real link so it opens in a new tab and announces as a link: render={<a href="…" />}.

  • disabled is the native attribute, so it works only on the button form: the button leaves the tab order and takes the disabled look. A link has no disabled. When a way somewhere is unavailable, don't render the link; say why in the text instead.

Rules

  • Don't use TextLink to fit one more action into a crowded row. It is the quietest control on a screen, not a smaller button.
  • Don't color it, and don't underline it at rest. Emphasis comes from weight and ink, so pink stays with the one primary button, and the underline stays the hover signal.

API

Prop类型默认值
variant"strong" | "muted""muted"
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

改动

  • 0.9.4 · ChangedClickable text no longer sits underlined at rest: it underlines on hover in its own colour and never turns pink. This covers TextLink (both emphases; strong no longer turns its underline pink on hover), MessageItemSenderButton, @ mentions, the forwarded-bundle and translation text actions, empty-state description links (now semibold so they stand apart from the hint text), the video-preview failure action and toast actions. Disabled ones do not underline. Rendered Markdown links are the one exception: they keep a faint underline at rest (link blue at 40%), because colour alone is below 3:1 against body text, and on hover the underline goes full strength and the text darkens.
  • 0.8.0 · Breaking ChangesButton no longer has variant="link" or size="inline". Underlined text is now TextLink. A link inside a sentence (a banner's "View Billing") becomes <TextLink variant="strong">; a link on its own (Forgot Password, See All) becomes <TextLink>, which is muted. TextLink has no height, border or padding, so drop the classes that took them off.
  • 0.8.0 · Breaking ChangesThe activity inbox sidebar no longer styles [data-activity-inbox-show-all] as a link (it keeps only whitespace-nowrap). Render Show All as a TextLink.
  • 0.8.0 · AddedTextLink: the bottom step of the button ladder, underlined text that takes the size of the text around it. It renders a button, or a real link with render={<a href="…" />}. variant="muted" (default) is for a link on its own; variant="strong" (ink, 600) is for a link inside a sentence.