Text allows the rendering of text and paragraphs within an interface.
const Example = () => {
return <Text>This is Text.</Text>;
};
const Example = () => {
return <VStack space={1} alignItems="center">
<Text fontSize="xs">xs</Text>
<Text fontSize="sm">sm</Text>
<Text fontSize="md">md</Text>
<Text fontSize="lg">lg</Text>
<Text fontSize="xl">xl</Text>
<Text fontSize="2xl">2xl</Text>
<Text fontSize="3xl">3xl</Text>
<Text fontSize="4xl">4xl</Text>
<Text fontSize="5xl">5xl</Text>
<Text fontSize="6xl">6xl</Text>
</VStack>;
};
const Example = () => {
return <Text isTruncated maxW="300" w="80%">
NativeBase gives you a contrasting color based on your theme. You can also
customise it using the useAccessibleColors hook.
</Text>;
};
const Example = () => {
return <Text italic>
<Text bold>Taj Mahal</Text> is in Agra.
</Text>;
};
const Example = () => {
return <VStack space={2} alignItems="center">
<Text bold>Bold</Text>
<Text italic>Italic</Text>
<Text underline>Underline</Text>
<Text highlight _dark={{
color: "coolgray.800"
}}>
Highlighted
</Text>
<Text>
H<Text sub>2</Text>O
</Text>
<Text underline>Underline</Text>
<Text strikeThrough>StrikeThrough</Text>
<Text bold italic underline>
Bold, Italic & Underline
</Text>
</VStack>;
};
Text implements
,
,
,
,
,
,
,
,
Renders components as Text children. Accepts a JSX.Element or an array of JSX.Element.
The size of font
Type: ResponsiveValue<number | "sm" | "2xs" | "xs" | "md" | "xl" | "3xl" | "5xl" | "lg" | "6xl" | "7xl" | "4xl" | "2xl" | (string & {}) | "8xl" | "9xl">
Letter spacing
Type: ResponsiveValue<number | "sm" | "xs" | "md" | "xl" | "lg" | "2xl" | (string & {})>
Line height
Type: ResponsiveValue<number | "sm" | "2xs" | "xs" | "md" | "xl" | "3xl" | "5xl" | "lg" | "4xl" | "2xl" | (string & {})>
Font weight
Type: ResponsiveValue<number | "bold" | "medium" | (string & {}) | "hairline" | "thin" | "light" | "normal" | "semibold" | "extrabold" | "black" | "extraBlack">
Fonts
Type: ResponsiveValue<IFont>
Used to truncate text at a specific number of lines
Used to make the text bold.
If true, it will render an ellipsis when the text exceeds the width of the viewport or maxWidth set.
Used to make the text italic.
Used to underline the text.
A horizontal line through the center of the text.
Text will have smaller font size.
Used to highlight the text with a yellow background.
NativeBase ships with a default theme for each component. Check out the default theme of the text
.
Info:
We can easily extend the text component theme using extendTheme function as described in the documentation .