外观
ButtonGroup 按钮组
把缩放、翻页等紧密相关的操作并排或垂直排列,共用连续的外边框。
import { SButtonGroup } from '@icecreamqaq/shadcn/button-group'使用示例
基础用法
button-group.vue组合式 API vue
<template>
<s-button-group aria-label="调整缩放">
<s-button variant="outline" type="button" :disabled="zoom <= 50" @click="zoom -= 10">缩小</s-button>
<s-button-group-text aria-live="polite">{{ zoom }}%</s-button-group-text>
<s-button variant="outline" type="button" :disabled="zoom >= 200" @click="zoom += 10">放大</s-button>
</s-button-group>
</template>
<script setup lang="ts">
import { ref } from "vue"
import { SButton } from "@icecreamqaq/shadcn/button"
import { SButtonGroup, SButtonGroupText } from "@icecreamqaq/shadcn/button-group"
const zoom = ref(100)
</script>vue
<template>
<s-button-group aria-label="调整缩放">
<s-button variant="outline" type="button" :disabled="zoom <= 50" @click="zoom -= 10">缩小</s-button>
<s-button-group-text aria-live="polite">{{ zoom }}%</s-button-group-text>
<s-button variant="outline" type="button" :disabled="zoom >= 200" @click="zoom += 10">放大</s-button>
</s-button-group>
</template>
<script lang="ts">
import { defineComponent } from "vue"
import { SButton } from "@icecreamqaq/shadcn/button"
import { SButtonGroup, SButtonGroupText } from "@icecreamqaq/shadcn/button-group"
export default defineComponent({
components: { SButton, SButtonGroup, SButtonGroupText },
data() {
return { zoom: 100 }
},
})
</script>常用 API
| 成员 | 类型 | 用法 |
|---|---|---|
SButtonGroup.orientation | "horizontal" | "vertical" | 默认横向排列。垂直排列会相应调整子项的边框和圆角。 |
SButtonGroupText | 组件 | 在组内显示缩放比例、页码或固定前缀。 |
SButtonGroupSeparator.orientation | "horizontal" | "vertical" | 分隔线默认为垂直方向,可放在相邻操作之间。 |
每个 SButton 独立处理点击和禁用状态。为整组设置 aria-label,可概括这些按钮共同控制的对象。
完整 API
ButtonGroup3 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
orientation | "vertical" | "horizontal" | null |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
ButtonGroupSeparator5 个成员
属性
| 名称 | 类型 |
|---|---|
orientation | DataOrientation |
decorative | boolean |
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
ButtonGroupText5 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
orientation | "vertical" | "horizontal" | null |
asChild | boolean |
as | AsTag | Component |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
分组导出
模板标签为 <s-button-group>。
组件 SButtonGroup、SButtonGroupSeparator、SButtonGroupText
函数与常量 buttonGroupVariants
类型 ButtonGroupVariants