react-native-directional-toggle
v0.1.1
Published
Multi-element toggle component for React Native and Expo with support for vertical and horizontal layouts and animations.
Readme
说明
这是一个 React Native / Expo 组件库。
注意:expo开发时,只能在prebuild后正常用expo run的方式运行,不支持expo go。
For English version, please click: English。
安装
pnpm add react-native-directional-toggle
yarn add react-native-directional-toggle依赖包
pnpm add react-native-gesture-handler react-native-reanimated react-native-worklets --save-peer需要安装的依赖包:
- react-native-gesture-handler
- react-native-reanimated
- react-native-worklets
使用
参考示例项目。
导入组件使用
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import Switcher from 'react-native-directional-toggle';
const options = [
{
label: 'Option 1',
value: 'Option 1',
},
{
label: 'Option 2',
value: 'Option 2',
},
{
label: 'Option 3',
value: 'Option 3',
},
];
...
<GestureHandlerRootView>
<Switcher
options={options}
value={'Option 2'}
height={36}
onChange={value => console.log(value)}
/>
</GestureHandlerRootView>
注意: App中需要在外层(如_layout.tsx等)包裹GestureHandlerRootView。
