Segmented 分段选择器
互斥选项切换,适合视图切换器场景。
基础用法
基础用法
当前值:list
第一行为受控用法并实时显示当前值;第二行 block 撑满容器,对象选项中 disabled: true 禁用单个选项;第三行 disabled 整组禁用。选项支持字符串快捷写法:
import { useState } from 'react'
import { LhSegmented } from '@lh-ui/react'
export default function Demo() {
const [value, setValue] = useState('list')
return <LhSegmented value={value} onChange={setValue} options={['列表', '卡片', '表格']} />
}
LhSegmented Props
| 属性 | 说明 | 类型 | 可选值 | 默认值 |
|---|---|---|---|---|
| value | 受控当前值(对应 plus 的 modelValue) | string | number | — | — |
| defaultValue | 非受控默认值 | string | number | — | — |
| options | 选项(字符串快捷写法或对象) | LhSegmentedInput[] | — | — |
| disabled | 整组禁用 | boolean | — | false |
| block | 撑满容器 | boolean | — | false |
| sx | 快速布局属性 | SxProps | — | — |