@uiw/react-native
Version:
UIW for React Native
110 lines (83 loc) • 2.71 kB
Markdown
SegmentedControl 分段器
---
由至少 2 个分段控件组成,用作不同视图的显示;是 iOS 的推荐组件。
```jsx mdx:preview&background=
import { Text } from 'react-native';
import { SegmentedControl } from '@uiw/react-native';
import React from 'react';
function Demo() {
return (
<SegmentedControl value={['申请', '审批', '提交']} />
);
}
export default Demo;
```
```jsx mdx:preview&background=
import { SegmentedControl } from '@uiw/react-native';
import React from 'react';
function Demo() {
return (
<SegmentedControl color="#dc3545" value={['申请', '审批', '提交']} />
);
}
export default Demo;
```
```jsx mdx:preview&background=
import { SegmentedControl } from '@uiw/react-native';
import React from 'react';
function Demo() {
return (
<SegmentedControl gutter={10} selectedIndex={2} value={['申请', '审批', '提交']} />
);
}
export default Demo;
```
```jsx mdx:preview&background=
import React from 'react';
import { SegmentedControl } from '@uiw/react-native';
function Demo() {
return (
<SegmentedControl disabled gutter={10} selectedIndex={2} value={['申请', '审批', '提交']} />
);
}
export default Demo;
```
```jsx mdx:preview&background=
import React from 'react';
import { SegmentedControl, Spacing } from '@uiw/react-native';
function Demo() {
return (
<>
<SegmentedControl size="large" gutter={10} selectedIndex={1} value={['申请', '审批', '提交']} />
<Spacing />
<SegmentedControl size="default" selectedIndex={2} value={['申请', '审批', '提交']} />
<Spacing />
<SegmentedControl size="small" gutter={10} selectedIndex={2} value={['申请', '审批', '提交']} />
</>
);
}
export default Demo;
```
组件继承 `ButtonGroup` 组件。
| 参数 | 说明 | 类型 | 默认值 |
|------|------|-----|------|
| `style` | 自定义样式 | Object | {} |
| `value` | 初始值 | String[] | [] |
| `color` | 组件主色调 | String | `
| `textColor` | 文本颜色 | Object: TextColorType | - |
| `size` | 按钮尺寸 | `small`, `default`, `large` | `default` |
| `disabled` | 是否启用 | Boolean | `false` |
| `selectedIndex` | 选中项在数组中的索引 | Number | 0 |
| `renderItem` | 自定义单元格 | (data, index, rowNum): void | - |
| `onValueChange` | 回调函数 | (label, selectedIndex): void | - |
| 参数 | 说明 | 类型 | 默认值 |
|------|------|-----|------|
| `actived` | 激活 | String | `
| `unactived` | 未激活 | String | `color` |