TextView

Updated: Sep 24, 2026
Use TextView for composed text in a custom layout. Select the typography with textStyle, the semantic color role with textColor, and the appropriate HTML semantics with as.
The component owns the toolkit font family, size, weight, line height, and optical block padding that aligns baselines. It also clears the browser’s default margin, border, and background so the rendered element adds no incidental spacing or decoration. The application owns layout and document structure.

Usage

import {TextColor, TextStyle, TextView} from '@wearables-ui-toolkit/mrbd';

function TrailSummary() {
  return (
    <div className="trail-summary">
      <TextView as="h2" textStyle={TextStyle.BODY2_EMPHASIZED}>
        Trail conditions
      </TextView>
      <TextView as="p" textStyle={TextStyle.BODY2}>
        The north overlook is open.
      </TextView>
      <TextView
        as="p"
        textStyle={TextStyle.META2}
        textColor={TextColor.SECONDARY}>
        UPDATED JUST NOW
      </TextView>
    </div>
  );
}
.trail-summary {
  display: grid;
  gap: var(--uit-spacing-med-lg);
}
All DOM attributes are forwarded, so a TextView can provide the id for an ARIA relationship. This keeps the visible heading and accessible section name connected:
import type {ReactNode} from 'react';
import {TextColor, TextStyle, TextView} from '@wearables-ui-toolkit/mrbd';

function RouteSection({children}: {children: ReactNode}) {
  return (
    <section aria-labelledby="route-heading">
      <TextView
        id="route-heading"
        as="h3"
        textStyle={TextStyle.LABEL_EMPHASIZED}>
        Route
      </TextView>
      <TextView
        as="p"
        textStyle={TextStyle.META1}
        textColor={TextColor.SECONDARY}>
        {children}
      </TextView>
    </section>
  );
}

Props

The complete prop type is TextViewProps. It extends HTMLAttributes<HTMLSpanElement> without color, and this attribute set remains the same for every element selected by as. Props not listed below, including id, aria-*, data-*, role, tabIndex, title, and DOM event handlers, are forwarded to the rendered element. The ref is forwarded to the same element.
PropTypeDefaultDescription
children
ReactNode
—
Text content to display.
textStyle
TextStyle
TextStyle.BODY1
Typography appearance applied to the content.
textColor
TextColor
TextColor.PRIMARY
Semantic foreground color applied to the content.
as
'span' \| 'p' \| 'div' \| 'h1' \| 'h2' \| 'h3' \| 'h4' \| 'h5' \| 'h6' \| 'label'
'span'
HTML element rendered by the component.
className
string
''
Class appended after the component’s own classes.
style
CSSProperties
{}
Styles merged after the resolved color, so they take precedence over it.

Types and enums

TextStyle selects a complete typography appearance. Its members are:
NUMERAL1, NUMERAL2, DISPLAY1, HEADING1, HEADING2, BODY1, BODY1_EMPHASIZED, BODY2, BODY2_EMPHASIZED, LABEL, LABEL_EMPHASIZED, META1, META1_EMPHASIZED, META2, META2_EMPHASIZED, META3.
Each member resolves to the corresponding TextAppearance constant and public typography class. See Typography for each appearance, recommended use, and class name. Custom markup that cannot use TextView can apply the same appearance class directly. A TextAppearance constant is a CSS class for an ordinary element; do not pass it as textStyle because that prop requires a TextStyle member.
TextColor selects a semantic foreground token.
TextColor memberColor token
PRIMARY
--uit-color-text-primary
SECONDARY
--uit-color-text-secondary
PLACEHOLDER
--uit-color-text-placeholder
ACTIVE_HOVER
--uit-color-text-active-hover
ACCENT
--uit-color-text-accent

Behavior

Color resolution.TextView writes the token selected by textColor as the rendered element’s inline color. Descendants inherit that value, and an icon painted with currentColor matches the text. The caller’s style object is merged afterward, so an explicit color in style takes precedence.
Secondary text blend.TextColor.SECONDARY also applies the uit-color-text-secondary class. This class provides both the semantic token and the lighten blend required by the additive-light display. The blend uses !important, so inline mixBlendMode cannot remove it. The secondary token without this class produces an incorrect display result.
Layout and sizing. The default element is an inline span, so adjacent default text views share a line and have no automatic separation. For stacked text, prefer block elements such as as="p" or a heading, with an explicit column layout and spacing tokens. TextView sizes to its content and does not provide truncation, ellipsis, clamping, or a line limit. Use ReadMoreTextView when content requires a line limit.
Class order. The component’s classes appear first, followed by className. Use the caller class for layout, spacing, and wrapping. Avoid using it to override the appearance class, because CSS specificity does not guarantee that result.
Ref. The ref points to the element selected by as but is typed as HTMLSpanElement. Cast it when the caller requires the more specific element type.
Memoization. The component is memoized. Prefer stable style objects and stable children so it can skip unnecessary renders; an inline object literal creates a new reference on each render.

Accessibility

  • Choose as from the document structure the content needs, rather than from its visual appearance. Pairing a heading element with a body appearance is a supported and typically preferred way to preserve the page outline.
  • TextView adds no role or accessible name. The application owns the semantics and accessible relationships for the rendered text.
  • Forwarded id, aria-*, data-*, role, and tabIndex props allow the text to participate in relationships such as aria-labelledby and aria-describedby.
  • TextViewProps does not include htmlFor, so as="label" cannot associate the component with a form control through that attribute. Use aria-labelledby, or render a native <label> and apply the appearance class directly, so the control receives an accessible label.
  • Decorative text must be marked aria-hidden by the application so assistive technology does not announce it. TextView does not hide content automatically.
  • Assign an explicit textStyle to each text view so its role remains clear if the default changes or the composition evolves.
  • Prefer body, label, and metadata appearances for routine hierarchy. Reserve heading, display, and numeral appearances for content that needs that visual emphasis.
  • Use as="p" and heading elements with a column layout and spacing tokens for stacked text. This gives the application predictable semantics and spacing.
  • Use className for layout, spacing, and wrapping, and use component props for appearance and semantic color.

Avoid

  • Avoid literal font family, size, weight, line height, letter spacing, or color values that imitate a toolkit appearance. Semantic typography and color choices keep display rendering consistent.
  • Do not apply the secondary color token without the class that provides its required blend, and do not try to cancel that blend with inline mixBlendMode. The additive-light display requires both parts.
  • Avoid placing adjacent default inline text views when the content needs visual separation; use layout and spacing tokens instead.
  • Prefer the component designed for clamping or truncation instead of reshaping text through style.