Tinyrack

Text

Typographic primitive that maps named text roles onto any element.

Contract

AxisValuesDefault
variantcaption, label, body, bodySm, code, headingSm, headingMd, headingLg, display, displayLgbody
colordefault, muted, placeholder, inverse, primary, info, success, warning, dangerinherit
asany element typespan

Install

pnpm add @tinyrack/ui

Scroll inside the code area to read long lines.

Styles

@import '@tinyrack/ui/components/text.css';

Scroll inside the code area to read long lines.

Imports

import { TRText } from '@tinyrack/ui/components/text';

Scroll inside the code area to read long lines.

Playground

Usage

Examples

Type roles permalink

Pick the role from meaning, then choose the element with the as prop so headings stay semantic.

Semantic color permalink

Reach for a color token by meaning; leave color unset to inherit the surrounding text color.

Alignment and truncation permalink

Logical alignment respects text direction, and truncate clamps a single overflowing line.

API

Options

PropTypeDefaultPurpose
variant'caption' | 'label' | 'body' | 'bodySm' | 'code' | 'headingSm' | 'headingMd' | 'headingLg' | 'display' | 'displayLg''body'Selects the named type role from the design tokens.
asElementType'span'Chooses the rendered element without changing the visual role.
color'default' | 'muted' | 'placeholder' | 'inverse' | 'primary' | 'info' | 'success' | 'warning' | 'danger'inheritApplies a semantic color token; unset inherits the parent color.
align'start' | 'center' | 'end'inheritSets logical text alignment for the current direction.
truncatebooleanfalseClamps a single overflowing line with an ellipsis.
weight'regular' | 'medium' | 'heading' | 'bold' | 'strong'role defaultOverrides the variant's font weight.

HTML and accessibility

TRText renders a span by default and forwards its native props, events, styles, and React 19 ref. Use as to render a semantic element—p, a heading, or label—independently of the visual variant, so headings keep document structure. It exports TRTextProps, TRTextVariant, TRTextColor, TRTextAlign, and TRTextWeight. Per-instance overrides are available through the --tr-text-* custom properties.