Text
Typographic primitive for body copy, muted descriptions, labels, captions, overlines, tabular numerals, and truncated text.
The quick brown fox jumps over the lazy dog.
123456789101112131415import { Text } from "#components/ui/base-ui/text.tsx";
export function Example() { return ( <> <Text variant="overline">Release notes</Text> <Text size="md">Atomic CSS compiled to zero-runtime classes.</Text> <Text variant="muted" size="sm">Updated 4 minutes ago</Text> <Text variant="mono" tabular="true">$14,280.00</Text>
{/* polymorphic composition via render */} <Text variant="label" render={<span />}>Inline span</Text> </> );}Variants
The quick brown fox jumps over the lazy dog.
bodyThe quick brown fox jumps over the lazy dog.
mutedThe quick brown fox jumps over the lazy dog.
subtleThe quick brown fox jumps over the lazy dog.
captionThe quick brown fox jumps over the lazy dog.
labelThe quick brown fox jumps over the lazy dog.
overlineThe quick brown fox jumps over the lazy dog.
monoSizes
The quick brown fox jumps over the lazy dog.
xsThe quick brown fox jumps over the lazy dog.
smThe quick brown fox jumps over the lazy dog.
mdThe quick brown fox jumps over the lazy dog.
lgThe quick brown fox jumps over the lazy dog.
xlThe quick brown fox jumps over the lazy dog.
2xlRoles & semantic tones
Combine role variants (overline, label, body, muted, caption, mono) with semantic status tones.
Telemetry overview
Production cluster healthy
All 14 regional edge nodes responded within target p95 budgets.
99.98% uptime
2 degraded jobs
0 critical alerts
Tabular numerals & truncation
Use tabular="true" for aligned figures in tables and truncate="true" for single-line ellipsis.
01,284.50 ms
00,042.10 ms
Long deployment description that truncates cleanly with an ellipsis on one line
Install
1npx stylexblocks add textSource
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134import * as stylex from "@stylexjs/stylex";import { createComponent } from "#lib/base-ui/create-component.tsx";import { defineRecipe } from "#lib/recipe-props.ts";import { colorPalette } from "@stylexblocks/ui/color-palette.stylex.ts";import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";import { fontSizes } from "@stylexblocks/ui/tokens/font-sizes.stylex.ts";import { fontWeights } from "@stylexblocks/ui/tokens/font-weights.stylex.ts";import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";import { letterSpacings } from "@stylexblocks/ui/tokens/letter-spacings.stylex.ts";import { lineHeights } from "@stylexblocks/ui/tokens/line-heights.stylex.ts";
const textStyles = stylex.create({ base: { fontFamily: fonts.body, marginTop: 0, marginBottom: 0, },});
const textVariants = stylex.create({ body: { color: semanticColors.fg, }, muted: { color: semanticColors.fgMuted, }, subtle: { color: semanticColors.fgSubtle, }, caption: { color: semanticColors.fgMuted, fontSize: fontSizes.xs, lineHeight: lineHeights.xs, }, label: { color: semanticColors.fg, fontWeight: fontWeights.medium, }, overline: { color: semanticColors.fgMuted, fontSize: fontSizes.xs, lineHeight: lineHeights.xs, fontWeight: fontWeights.semibold, letterSpacing: letterSpacings.wider, textTransform: "uppercase", }, mono: { fontFamily: fonts.mono, color: semanticColors.fg, },});
const textSizes = stylex.create({ "2xs": { fontSize: fontSizes._2xs, lineHeight: lineHeights._2xs }, xs: { fontSize: fontSizes.xs, lineHeight: lineHeights.xs }, sm: { fontSize: fontSizes.sm, lineHeight: lineHeights.sm }, md: { fontSize: fontSizes.md, lineHeight: lineHeights.md }, lg: { fontSize: fontSizes.lg, lineHeight: lineHeights.lg }, xl: { fontSize: fontSizes.xl, lineHeight: lineHeights.xl }, "2xl": { fontSize: fontSizes._2xl, lineHeight: lineHeights._2xl },});
const textTones = stylex.create({ inherit: {}, default: { color: semanticColors.fg }, muted: { color: semanticColors.fgMuted }, subtle: { color: semanticColors.fgSubtle }, accent: { color: colorPalette.fg }, success: { color: semanticColors.fgSuccess }, warning: { color: semanticColors.fgWarning }, error: { color: semanticColors.fgError }, info: { color: semanticColors.fgInfo },});
const textWeights = stylex.create({ inherit: {}, normal: { fontWeight: fontWeights.normal }, medium: { fontWeight: fontWeights.medium }, semibold: { fontWeight: fontWeights.semibold }, bold: { fontWeight: fontWeights.bold },});
const textAligns = stylex.create({ start: { textAlign: "start" }, center: { textAlign: "center" }, end: { textAlign: "end" },});
const textTruncate = stylex.create({ false: {}, true: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", },});
const textTabular = stylex.create({ false: {}, true: { fontVariantNumeric: "tabular-nums", },});
const textRecipe = defineRecipe({ styles: textStyles, axes: { size: textSizes, variant: textVariants, tone: textTones, weight: textWeights, align: textAligns, truncate: textTruncate, tabular: textTabular, }, defaultVariants: { size: "sm", variant: "body", tone: "inherit", weight: "inherit", align: "start", truncate: "false", tabular: "false", },});
/** * Text — typographic primitive for body copy, muted descriptions, labels, * captions, overlines, tabular numbers, and truncated single-line text. * Composition via `render`. */export const Text = createComponent("p", textRecipe, "Text");export type TextProps = React.ComponentProps<typeof Text>;