外观
ToggleGroup 切换按钮组
以紧凑的一排按钮表达单选或多选,例如提醒日期、对齐方式或显示模式。
import { SToggleGroup } from '@icecreamqaq/shadcn/toggle-group'使用示例
常用 API
| 成员 | 类型 | 用法 |
|---|---|---|
SToggleGroup.type | "single" | "multiple" | 决定组内是单选还是多选。 |
SToggleGroup.v-model | AcceptableValue | AcceptableValue[] | 单选模式使用单个值,多选模式使用数组。 |
SToggleGroupItem.value | AcceptableValue | 记录到组模型中的标识。 |
SToggleGroup.spacing | number | 使用组件库的间距刻度指定项目间隔,默认为 0。 |
完整 API
ToggleGroup21 个成员
属性
| 名称 | 类型 |
|---|---|
rovingFocus | boolean |
disabled | boolean |
orientation | DataOrientation |
dir | Direction |
loop | boolean |
asChild | boolean |
as | AsTag | Component |
name | string |
required | boolean |
type | SingleOrMultipleType |
modelValue | AcceptableValue | AcceptableValue[] |
defaultValue | AcceptableValue | AcceptableValue[] |
options | readonly CollectionItem<string | number>[] |
renderLabel | RenderContent<{ item: CollectionItem<string | number>; }> |
class | ClassValue |
variant | "default" | "outline" | null |
size | "default" | "sm" | "lg" | null |
spacing | number |
事件
| 名称 | 类型 |
|---|---|
update:modelValue | ((payload: AcceptableValue | AcceptableValue[]) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: { modelValue: AcceptableValue | AcceptableValue[] | undefined; }) => any) |
label | ((props: { item: CollectionItem<string | number>; }) => any) |
ToggleGroupItem8 个成员
属性
| 名称 | 类型 |
|---|---|
value 必填 | AcceptableValue |
asChild | boolean |
as | AsTag | Component |
disabled | boolean |
class | ClassValue |
variant | "default" | "outline" | null |
size | "default" | "sm" | "lg" | null |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: { modelValue: boolean; state: "on" | "off"; pressed: boolean; disabled: boolean; }) => any) |
分组导出
模板标签为 <s-toggle-group>。
组件 SToggleGroup、SToggleGroupItem