primitives

Text

Typography primitive. Sized via a scale, weighted via an enum, polymorphic on the element.


Text is plyxui's typography primitive. Sized via a small enum (xs to 3xl), weighted via four named weights, color resolved against the theme, polymorphic on the element via the as prop on web.

API

<Text size="md" weight="semibold" color="text">
  Hello.
</Text>

<Text as="h2" size="2xl" weight="bold">Page title</Text>
<Text as="p"  size="md"  color="textMuted">Subtitle copy.</Text>
<Text size="sm" truncate>This will ellipsis if it overflows.</Text>

Props

PropTypeDefault
asElementType (web only)"span"
size"xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl""md"
weight"regular" | "medium" | "semibold" | "bold""regular"
colortheme token key OR raw CSS colorcolors.text
align"start" | "center" | "end"-
truncateboolean (single-line ellipsis)false

Size scale

SizeWebNative
xs11 / 1611 / 16
sm13 / 1813 / 18
md15 / 2215 / 22
lg18 / 2618 / 26
xl22 / 3022 / 30
2xl28 / 3628 / 36
3xl36 / 4436 / 44

Values are font-size / line-height in pixels. Same on web and native; the native variant uses unitless line-height (RN convention).

Native

The native variant ignores as (always renders RN.Text), but every other prop matches. truncate maps to numberOfLines={1}.