Style parts of text to improve readability, increase positive user experience, and encourage greater creativity through use of colors and fonts. Inspired from Jetpack Compose.
Fully compatible with TypeScript & Turbomodules.
Required React Native Version >=0.72.0
Platform | Support |
---|---|
iOS | ✅ |
Android | ✅ |
Web | ❌ |
Windows | ❌ |
macOS | ❌ |
npm install @rn-org/react-native-annotated-text @react-native-masked-view/masked-view react-native-linear-gradient
or
yarn add @rn-org/react-native-annotated-text @react-native-masked-view/masked-view react-native-linear-gradient
import { AnnotatedText } from '@rn-org/react-native-annotated-text';
<AnnotatedText
annotatedString={(append, withStyle) => {
withStyle({ color: "blue" }, () => append('Hello World'));
}}
/>

import { AnnotatedText } from '@rn-org/react-native-annotated-text';
<AnnotatedText
annotatedString={(append, withStyle) => {
withStyle({ fontSize: 20 }, () => append('Hello World'));
}}
/>

Use the fontStyle
parameter to italicize text.
import { AnnotatedText } from '@rn-org/react-native-annotated-text';
<AnnotatedText
annotatedString={(append, withStyle) => {
withStyle({ fontStyle: "italic" }, () => append('Hello World'));
}}
/>

Use the fontWeight
parameter to bold text (or set another FontWeight).
import { AnnotatedText } from '@rn-org/react-native-annotated-text';
<AnnotatedText
annotatedString={(append, withStyle) => {
withStyle({ fontWeight: "bold" }, () => append('Hello World'));
}}
/>

import { AnnotatedText } from '@rn-org/react-native-annotated-text';
<AnnotatedText
annotatedString={(append, withStyle) => {
withStyle({ color: "blue" }, () => append('H'));
append("ello ")
withStyle({ color: "red" }, () => append('W'));
append("orld")
}}
/>

import { AnnotatedText } from '@rn-org/react-native-annotated-text';
<AnnotatedText
annotatedString={(append, withStyle) => {
withStyle(
{},
() => append('Hello World'),
['#FF0000', '#0000FF']
);
}}
/>


import { AnnotatedText } from '@rn-org/react-native-annotated-text';
<AnnotatedText
annotatedString={(append, withStyle) => {
withStyle({ fontSize: 24 }, () => append('Hello '));
withStyle(
{ fontWeight: 'bold', fontSize: 24 },
() => append('Gradient'),
['#FF0000', '#0000FF']
);
withStyle({ fontSize: 24 }, () => append(' World!'));
}}
/>


To run example app, follow the below steps
- Clone the repository
- Do
yarn install
- For android
yarn example android
- For iOS
cd ios
and dobundle exec pod install
and run the iOS app from XCode