Command palette

@yasinsensoy/native

React Native · Components

Text

Text in the theme color and the library's type scale.

4 exports

Import

import { Text } from "@yasinsensoy/native";

Text

component

Text in the theme color and the library's type scale. Headings (h1–h4) are reported to screen readers as headings. Variant sizes scale with the device (UIProvider scaling); numbers you give in style stay as is (scale them with useScale().fs() or createStyles).

Text({ ref, variant, tone, weight, italic, align, style, maxFontSizeMultiplier, ...props }: TextProps): JSX.Element

Examples

`<Text variant="h2">Profile</Text>` · `<Text tone="muted" variant="sm">Description</Text>`

Text style; sizes match the Tailwind scale on web.

  • body: 16/24 (readable body text on mobile).
  • sm: 14/20. xs: 12/16. lg: 18/28.
  • h1 30/36 bold, h2 24/32 semibold, h3 20/28 semibold, h4 18/28 semibold.
  • label: 14/20 medium (form label).
type TextVariant = "body" | "sm" | "xs" | "lg" | "h1" | "h2" | "h3" | "h4" | "label"

Text color: one of the theme colors.

type TextTone = "default" | "muted" | "primary" | "danger" | "success" | "warning"

TextProps

interface

Text props.

Extends: NativeTextProps

NameTypeDefaultDescription
ref?Ref<TextRef>Ref of the underlying native element.
variant?TextVariant"body"Style. See TextVariant.
tone?TextTone"default"` (theme `foreground`)Color.
weight?FontWeightInputWeight; overrides the style's weight. For fonts with a file per weight (e.g. inter) the right file is chosen; fontWeight / fontStyle: "italic" inside style resolve the same way.
italic?booleanItalic text (the font's italic file is used if it has one).
align?TextStyle["textAlign"]Alignment.