patrickkabwe/react-native-nitro-text
关于
A Text component that is much richer and performant for both iOS and Android.
网站与应用开发可以做什么
- Works on both iOS and Android(currently fallback to RN Text on Android)
- Native iOS rendering with smooth selection.
- Nested fragments merge into a single native text view
- Supports only the New Architecture
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文react-native-nitro-text
A Text component that is much richer and performant for both iOS and Android.
Features
- Works on both iOS and Android(currently fallback to RN
Texton Android) - Native iOS rendering with smooth selection.
- Nested fragments merge into a single native text view
- Supports only the New Architecture
Requirements
- React Native v0.78.0 or higher (Fabric/Nitro Views)
- Node 18+ (Node 20+ recommended)
Installation
yarn add react-native-nitro-text react-native-nitro-modules
iOS
cd ios && pod install && cd ..
That’s it. You can now use the NitroText component in your app.
Usage
import { NitroText as Text } from 'react-native-nitro-text'
export function Title() {
return (
<Text style={{ fontSize: 24, fontWeight: 'bold' }}>
🚀 NitroText Showcase
</Text>
)
}
Selection
iOS uses native selection. On Android, NitroText currently falls back to React Native Text.
import { NitroText as Text } from 'react-native-nitro-text'
export function SelectionExample() {
return (
<Text selectable style={{ fontSize: 16, lineHeight: 22 }}>
Long-press to select this text. NitroText supports smooth selection,
even with <Text style={{ fontWeight: '600' }}>inline styles</Text> and
longer paragraphs.
</Text>
)
}
Custom selection menu
NitroText supports custom menu items that appear when text is selected. Pass a menus prop with an array of menu items, each containing a title and action callback.
import { NitroText } from 'react-native-nitro-text'
import { useMemo } from 'react'
export function MenuExample() {
const menus = useMemo(
() => [
{
title: 'Copy',
action: () => console.log('Copy action')
},
{
title: 'Share',
action: () => console.log('Share action')
},
{
title: 'Translate',
action: () => console.log('Translate action')
},
],
[]
)
return (
<NitroText selectable menus={menus} style={{ fontSize: 16 }}>
Select this text to see custom menu options appear in the selection menu.
</NitroText>
)
}
Platform Support
- iOS
- Android - At the moment
NitroTextfallback to RNText.
Why NitroText?
Custom native text view with minimal JS overhead and native iOS selection. Great for heavy/nested styled text and large lists. It's a drop-in replacement for RN Text component.
Development
bun run build— typecheck and build the packagebun run codegen— regenerate codegen outputs- Example app in
example/
Credits
Bootstrapped with create-nitro-module.
Contributing
PRs welcome! Please open an issue first for major changes.
💬 For quick support, join our Discord channel
探索相关项目
加载中…