Text

Looking to add text to your gluestack-ui project? Check out our text component, which supports paragraphs and other formatting options.
Installation
API Reference
This is an illustration of Text component.
<Text>Hello World!</Text>

Installation

Step 1: Copy and paste the following code into your project.

import React from "react"
import { tva } from "@gluestack-ui/nativewind-utils"
import { Text as RNText } from "react-native"
const textStyle = tva({
base: "text-typography-700 font-normal font-body",
variants: {
isTruncated: {
true: "web:truncate",
},
bold: {
true: "font-bold",
},
underline: {
true: "underline",
},
strikeThrough: {
true: "line-through",
},
size: {
"2xs": "text-2xs",
xs: "text-xs",
sm: "text-sm",
md: "text-md",
lg: "text-lg",
xl: "text-xl",
"2xl": "text-2xl",
"3xl": "text-3xl",
"4xl": "text-4xl",
"5xl": "text-5xl",
"6xl": "text-6xl",
},
sub: {
true: "text-xs",
},
italic: {
true: "italic",
},
highlight: {
true: "bg-yellow-500",
},
},
})
const Text = ({
className,
isTruncated,
bold,
underline,
strikeThrough,
size = "md",
sub,
italic,
highlight,
...props
}: any) => {
return (
<RNText
className={textStyle({
isTruncated,
bold,
underline,
strikeThrough,
size,
sub,
italic,
highlight,
class: className,
})}
/>
)
}
Text.displayName = "Text"
export { Text }

Step 2: Update the import paths to match your project setup.

API Reference

To use this component in your project, include the following import statement in your file.
import { Text } from "@/components/ui/Text"
export default () => <Text />

Component Props

This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.

Text

It inherits all the properties of React Native's Text component.

Props

Text component is created using Text component from react-native. It extends all the props supported by React Native Text, utility props and the props mentioned below.

Text

Name
Value
Default
isTruncated
true
false
bold
true
false
underline
true
false
strikeThrough
true
false
sub
true
false
italic
true
false
highlight
true
false
size
2xs | xs | sm | md | lg | xl | 2xl | 3xl | 4xl | 5xl | 6xl
md
Edit this page on GitHub