react-native-wiser-selectable-text
v0.1.1
Published
Selectable text for React Native with native menu actions and built-in highlight overlay
Downloads
208
Maintainers
Readme
react-native-wiser-selectable-text
Selectable text component for React Native with:
- Custom selection menu actions
- Native
onSelectionChangeandonActionPressevents - Persistent highlights (
highlights+highlightColor) - iOS + Android support
Install
yarn add react-native-wiser-selectable-textiOS:
cd ios && pod installUsage
import SelectableText from 'react-native-wiser-selectable-text';
<SelectableText
text="Hello world"
menuConfig={{
actions: [
{ id: 'copy', title: 'Copy' },
{ id: 'highlight', title: 'Highlight' },
],
}}
highlights={[{ id: '1', start: 0, end: 5 }]}
highlightColor="#FFEB3B88"
onActionPress={(event) => {
const { actionId, selectedText, start, end } = event.nativeEvent;
console.log(actionId, selectedText, start, end);
}}
/>Props
text?: stringchildren?: React.ReactNodemenuConfig?: { actions?: Array<{ id: string; title: string }> }highlights?: Array<{ id: string; start: number; end: number }>highlightColor?: ColorValueonSelectionChange?: ({ nativeEvent: { start, end, selectedText } }) => voidonActionPress?: ({ nativeEvent: { actionId, title, start, end, selectedText } }) => void- Text style props via
style(fontFamily,fontSize,fontWeight,fontStyle,lineHeight,letterSpacing,textAlign,color)
License
MIT
