Skip to content
Browse documentation
whisk/ui

Text

Render readable body text with shared typography tokens.

Overview

Text renders a paragraph with the shared type scale, semantic colors, truncation, and line clamping.

Use when

You are rendering a paragraph, supporting copy, or a short textual value.

Use instead

Use Heading for document structure, Code for inline code, and Link for navigation.

Usage

Invite teammates after the workspace is ready.

import { Text } from "@smoothie-framework/whisk-react";

<Text color="subtle">
  Invite teammates after the workspace is ready.
</Text>

Examples

Sizes

Use size to choose a value from the shared type scale without changing paragraph semantics.

Extra-small text

Small text

Medium text

Large text

Extra-large text

import { Stack, Text } from "@smoothie-framework/whisk-react";

<Stack gap={2}>
  <Text size="xs">Extra-small text</Text>
  <Text size="sm">Small text</Text>
  <Text size="md">Medium text</Text>
  <Text size="lg">Large text</Text>
  <Text size="xl">Extra-large text</Text>
</Stack>

Weights

Use weight for visual emphasis only. Use Heading when text introduces a section in the document outline.

Light text

Normal text

Medium text

Semibold text

Bold text

import { Stack, Text } from "@smoothie-framework/whisk-react";

<Stack gap={2}>
  <Text weight="light">Light text</Text>
  <Text weight="normal">Normal text</Text>
  <Text weight="medium">Medium text</Text>
  <Text weight="semibold">Semibold text</Text>
  <Text weight="bold">Bold text</Text>
</Stack>

Semantic colors

Use semantic colors to express supporting, informational, error, and success states. Keep the surrounding text understandable without color alone.

Updated 2 minutes ago

New in this release

Payment method needs attention

Changes saved

import { Stack, Text } from "@smoothie-framework/whisk-react";

<Stack gap={2}>
  <Text color="subtle">Updated 2 minutes ago</Text>
  <Text color="accent">New in this release</Text>
  <Text color="error">Payment method needs attention</Text>
  <Text color="success">Changes saved</Text>
</Stack>

Inline emphasis

In React, use native inline elements inside Text when part of a paragraph needs emphasis. This preserves one paragraph instead of nesting Text components.

Review every production change before publishing.

import { Text } from "@smoothie-framework/whisk-react";

<Text>
  Review <strong>every production change</strong> before publishing.
</Text>

Truncation

Use truncate for compact single-line values. Do not use it for instructions, errors, or other text someone must be able to read in full.

design-system-release-notes-for-october.md

import { Box, Text } from "@smoothie-framework/whisk-react";

<Box maxW="18rem" padding={3} background="surface2" rounded="md">
  <Text truncate>design-system-release-notes-for-october.md</Text>
</Box>

Line clamp

Use maxLines when the layout has a fixed amount of room and the full text remains available elsewhere. Give the text a constrained width so it can overflow.

This release adds activity filters, workspace roles, and a clearer audit history for every change.

import { Box, Text } from "@smoothie-framework/whisk-react";

<Box maxW="18rem" padding={3} background="surface2" rounded="md">
  <Text maxLines={2}>
    This release adds activity filters, workspace roles, and a clearer audit history for every change.
  </Text>
</Box>

Ref

Text forwards its ref to the paragraph element, so an application can expose the full value in a native tooltip only when a truncated filename actually overflows.

design-system-release-notes-for-october.md

import { useEffect, useRef, useState } from "react";
import { Text } from "@smoothie-framework/whisk-react";

export function FileName() {
  const fileName = "design-system-release-notes-for-october.md";
  const textRef = useRef<HTMLParagraphElement | null>(null);
  const [truncated, setTruncated] = useState(false);

  useEffect(() => {
    const node = textRef.current;
    if (node) setTruncated(node.scrollWidth > node.clientWidth);
  }, []);

  return (
    <Text ref={textRef} truncate maxW="18rem" title={truncated ? fileName : undefined}>
      {fileName}
    </Text>
  );
}

Props

Component props

PropTypeDefaultDescription
size2xs | xs | sm | md | lg | xl | 2xl | 3xl | 4xl | 5xl | 6xl | 7xl | 8xl | 9xlmdChoose a value from the shared type scale.
weightthin | light | normal | medium | semibold | bold | extraboldnormalAdjust visual emphasis without turning text into a heading.
alignleft | center | right | justifyleftSet paragraph alignment.
colordefault | subtle | disabled | inverse | accent | error | success | warning | stringdefaultUse the shown semantic names first. Values such as text-subtle are raw theme color tokens, not semantic aliases; pass them as strings and declare static values in utilityUses.
truncate | maxLinesResponsive<boolean> | Responsive<UtilityValue>false | noneTruncate one line or clamp a known number of lines. The containing layout must give the text a width to overflow.

Shared props

PropSupportedNotes
as / asChildYesChoose the text host with as, or merge Text props into one child with asChild.
Style propsYesUse the shared static style-prop surface. See Style props.
className / styleYesApplied to the text host.
refYesForwards to the text host.
Native HTML attributesYesNative paragraph attributes are forwarded.

Accessibility

Text renders a paragraph by default, so do not nest it inside another paragraph or use it to imitate a heading. Keep readable contrast and do not rely on color, weight, or case alone to convey meaning. Use as or asChild to choose an inline host when the surrounding semantics require it, and use Code for literal values.