feat: add Checkbox and Radio field families
This commit is contained in:
@@ -2,7 +2,11 @@
|
||||
import { IconCode, IconCopy } from "@tabler/icons-vue";
|
||||
import { computed, ref, watch, onBeforeUnmount, useId } from "vue";
|
||||
import { highlights } from "virtual:docs-data";
|
||||
const props = defineProps<{ name: string }>();
|
||||
const props = defineProps<{
|
||||
name: string;
|
||||
align?: "center" | "start" | "end";
|
||||
isBgSolid?: boolean;
|
||||
}>();
|
||||
const demos = import.meta.glob("../../demos/*.vue", {
|
||||
eager: true,
|
||||
import: "default",
|
||||
@@ -53,7 +57,18 @@ onBeforeUnmount(() => clearTimeout(timer));
|
||||
</script>
|
||||
<template>
|
||||
<div class="component-preview-container" :data-name="name">
|
||||
<div class="preview not-prose">
|
||||
<div
|
||||
class="preview not-prose"
|
||||
:style="{
|
||||
alignItems:
|
||||
align === 'start'
|
||||
? 'flex-start'
|
||||
: align === 'end'
|
||||
? 'flex-end'
|
||||
: undefined,
|
||||
background: isBgSolid ? 'var(--background)' : undefined,
|
||||
}"
|
||||
>
|
||||
<div class="demo-row">
|
||||
<component :is="component" v-if="component" />
|
||||
<p v-else role="alert">示例不存在:{{ name }}</p>
|
||||
|
||||
@@ -51,6 +51,8 @@ const groups = [
|
||||
{ title: "Badge 徽章", url: "/components/badge" },
|
||||
{ title: "Button 按钮", url: "/components/button" },
|
||||
{ title: "Card 卡片", url: "/components/card" },
|
||||
{ title: "Checkbox 复选框", url: "/components/checkbox" },
|
||||
{ title: "CheckboxGroup 复选框组", url: "/components/checkbox-group" },
|
||||
{ title: "Chip 标签", url: "/components/chip" },
|
||||
{ title: "CloseButton 关闭按钮", url: "/components/close-button" },
|
||||
{ title: "Description 描述", url: "/components/description" },
|
||||
@@ -61,6 +63,7 @@ const groups = [
|
||||
{ title: "Kbd 键盘按键", url: "/components/kbd" },
|
||||
{ title: "Label 标签", url: "/components/label" },
|
||||
{ title: "Link 链接", url: "/components/link" },
|
||||
{ title: "RadioGroup 单选框组", url: "/components/radio-group" },
|
||||
{ title: "SearchField 搜索框", url: "/components/search-field" },
|
||||
{ title: "Separator 分隔符", url: "/components/separator" },
|
||||
{ title: "Skeleton 骨架屏", url: "/components/skeleton" },
|
||||
|
||||
@@ -28,3 +28,7 @@ description: 已迁移组件及文档
|
||||
|
||||
- [Fieldset 字段组](./components/fieldset)
|
||||
- [SearchField 搜索框](./components/search-field)
|
||||
|
||||
- [Checkbox 复选框](./components/checkbox)
|
||||
- [CheckboxGroup 复选框组](./components/checkbox-group)
|
||||
- [RadioGroup 单选框组](./components/radio-group)
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
---
|
||||
title: CheckboxGroup 复选框组
|
||||
description: 用于管理多个复选框选择的复选框组组件
|
||||
icon: updated
|
||||
component: checkbox-group
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Checkbox,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Label,
|
||||
Description,
|
||||
FieldError,
|
||||
CheckboxGroup,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-group-basic"
|
||||
/>
|
||||
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Checkbox,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Label,
|
||||
Description,
|
||||
FieldError,
|
||||
CheckboxGroup,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CheckboxGroup>
|
||||
<Label>选择选项</Label>
|
||||
<Checkbox value="option">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl><CheckboxIndicator /></CheckboxControl>
|
||||
<Label>选项</Label>
|
||||
</CheckboxContent>
|
||||
<Description />
|
||||
</Checkbox>
|
||||
<FieldError />
|
||||
</CheckboxGroup>
|
||||
</template>
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### 表面样式
|
||||
|
||||
在 [Surface](/components/surface) 组件内使用时,请使用 `variant="secondary"` 以应用适合 Surface 背景的低强调变体。
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-group-on-surface"
|
||||
/>
|
||||
|
||||
### 禁用
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-group-disabled"
|
||||
/>
|
||||
|
||||
### 半选状态
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-group-indeterminate"
|
||||
/>
|
||||
|
||||
### 受控组件
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-group-controlled"
|
||||
/>
|
||||
|
||||
### 表单校验
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-group-validation"
|
||||
/>
|
||||
|
||||
### 功能扩展示例
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-group-features-and-addons"
|
||||
/>
|
||||
|
||||
### 自定义指示器
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-group-with-custom-indicator"
|
||||
/>
|
||||
|
||||
### 渲染函数
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-group-render-function"
|
||||
/>
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="checkbox-group-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
可使用 `@layer components` 指令自定义 CheckboxGroup 组件类。
|
||||
[了解更多](https://tailwindcss.com/docs/adding-custom-styles#adding-component-classes)。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-checkbox-group {
|
||||
@apply flex flex-col gap-2;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
|
||||
|
||||
### CSS 类
|
||||
|
||||
CheckboxGroup 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/checkbox-group.css)):
|
||||
|
||||
#### 基础类
|
||||
|
||||
- `.hv-checkbox-group` - 复选框组根容器
|
||||
|
||||
## API 参考
|
||||
|
||||
本库采用原生 label/input 承载选择与提交,复用共享字段、Form、Fieldset 禁用和错误协议。原生输入是唯一的提交值来源;组内没有 Reka 的重复隐藏值或带索引字段名。组校验另有无 name、不可 Tab 聚焦的约束代理,不产生 FormData 条目。
|
||||
|
||||
### CheckboxGroup
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| -------------------------- | ---------------------------------------------------------------------- | ---------------------- | -------------------------------------- |
|
||||
| `modelValue` | `string[]` | 非受控 | 当前值,使用 v-model |
|
||||
| `defaultValue` | `string[]` | `[]` | 非受控初始值副本 |
|
||||
| `name` / `form` / `id` | `string` | - / - / 自动 | 统一原生提交键、表单归属及组 ID |
|
||||
| `variant` | `'primary' \| 'secondary'` | `'primary'` | 组视觉样式;Checkbox 成员可显式覆盖 |
|
||||
| `isDisabled` / `disabled` | `boolean` | `false` | 合并 Fieldset 禁用,后代不能解除 |
|
||||
| `isReadOnly` | `boolean` | `false` | 阻止成员点击、空格和方向键修改 |
|
||||
| `isRequired` / `isInvalid` | `boolean` | `false` | 要求至少一项可用选择 / 错误展示 |
|
||||
| `validate` | `(value: string[]) => string \| string[] \| true \| null \| undefined` | - | 同步组校验 |
|
||||
| `validationBehavior` | `'native' \| 'aria'` | 继承 Form,否则 native | 原生提交拦截或仅错误语义 |
|
||||
| `class` / `style` | Vue class/style 绑定 | - | 合并根样式,接受字符串/数组/对象 class |
|
||||
| 默认插槽 | 作用域插槽 | - | 标签、说明、成员、错误 |
|
||||
|
||||
### 事件与暴露
|
||||
|
||||
| 接口 | 行为 |
|
||||
| ------------------------------ | ---------------------------------------------------------------------- |
|
||||
| `update:modelValue` / `change` | 发出新的数组或标量;不修改传入数组;父级拒绝后恢复所有原生 checked |
|
||||
| `focus()` / `element` | 聚焦选中可用成员或首个可用成员;空组聚焦组根。element 是组 HTMLElement |
|
||||
|
||||
CheckboxGroup 按原生约定提交同名重复条目,通过 FormData.getAll(name) 获取;RadioGroup 只提交一个选中可用值。未指定 name 不产生提交值。每个成员 value 必须唯一;重复或动态改成重复值会抛出明确错误。不为移除的选择自动选择别的成员;模型保留调用者的值,FormData 只包含实际存在的可用成员。
|
||||
|
||||
required 检查整个组,不能让每个 Checkbox 都变成必选;native 无效提交聚焦第一个可用成员,空组聚焦根。只读保留提交值并跳过必填/自定义约束。reset 尊重 preventDefault,受控值不覆盖,非受控恢复初始副本。动态 name/form 会更新提交和 reset 归属。
|
||||
|
||||
Label 在组中渲染 span 并注册 aria-labelledby;不要手写 for 指向组 div。每个成员独立隔离 Description/FieldError,同时合并组描述和当前组错误。后端错误使用 Form.validationErrors 按 name 映射,编辑后忽略当前响应,新对象可恢复错误。暂不提供异步 validate 或完整 validationDetails。
|
||||
|
||||
### CheckboxContent / Control / Indicator
|
||||
|
||||
| 部件 | 根与插槽 | 属性落点 |
|
||||
| --------- | ------------------------------------------ | ------------------------------------------ |
|
||||
| Content | 原生 label,包含实际 input;默认作用域插槽 | class/style/原生 label 属性及事件 |
|
||||
| Control | span,默认插槽 | class/style/DOM 属性与事件 |
|
||||
| Indicator | span,默认作用域插槽 | 装饰 aria-hidden;自定义内容替换基线指示器 |
|
||||
|
||||
具名导出使用 CheckboxContent、CheckboxControl、CheckboxIndicator;不使用 React 对象式子部件。class 均支持字符串、数组和对象。默认图形精确来自基线,文档自定义图标使用 Tabler。Content 输出 selected/indeterminate/hovered/pressed/focus-visible 状态标记供定制样式使用。
|
||||
|
||||
### 作用域插槽状态
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| ---------------------------------------------------------- | --------- | ------------------------------ |
|
||||
| `isSelected` / `isIndeterminate` | `boolean` | 选中 / 半选(半选仅 Checkbox) |
|
||||
| `isDisabled` / `isReadOnly` / `isRequired` / `isInvalid` | `boolean` | 当前状态 |
|
||||
| `isHovered` / `isPressed` / `isFocused` / `isFocusVisible` | `boolean` | 单成员交互状态 |
|
||||
|
||||
组作用域提供 value、validationErrors、isDisabled/isReadOnly/isRequired/isInvalid,以及 state.value/state.setValue;单成员另提供 state.isSelected/state.setSelected/state.toggle。不把组值和单成员状态混用。
|
||||
|
||||
### 框架适配与边界
|
||||
|
||||
render 自定义根类型未支持;基线 div+data-custom 示例以 Vue 根属性透传保留效果。SSR 预规划直接/原生/Fragment 包裹的标签、说明、错误与直接成员;本库 Content 内的说明也支持。任意用户 Vue 包装组件无法静态展开,需要显式 aria-labelledby/aria-describedby 和 ID 保证首屏关联。没有宣称完整读屏、触屏、Nuxt 或逐像素验收。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Checkbox](./checkbox) · [CheckboxGroup](./checkbox-group) · [RadioGroup](./radio-group) · [Fieldset](./fieldset)
|
||||
@@ -0,0 +1,269 @@
|
||||
---
|
||||
title: Checkbox 复选框
|
||||
description: 复选框允许用户从列表中选择多项,或标记单个项目为选中状态
|
||||
icon: updated
|
||||
component: checkbox
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Checkbox,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Label,
|
||||
Description,
|
||||
FieldError,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-basic"
|
||||
/>
|
||||
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Checkbox,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Label,
|
||||
Description,
|
||||
FieldError,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Checkbox>
|
||||
<CheckboxContent>
|
||||
<CheckboxControl><CheckboxIndicator /></CheckboxControl>
|
||||
<Label>选项</Label>
|
||||
</CheckboxContent>
|
||||
<Description />
|
||||
</Checkbox>
|
||||
</template>
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### 变体
|
||||
|
||||
Checkbox 组件支持两种视觉变体:
|
||||
|
||||
- **`primary`**(默认)- 标准样式与默认背景,适用于大多数场景
|
||||
- **`secondary`** - 低强调变体,适用于 Surface 组件内
|
||||
|
||||
<ComponentPreview name="checkbox-variants" />
|
||||
|
||||
### 全圆角
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-full-rounded"
|
||||
/>
|
||||
|
||||
### 禁用
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-disabled"
|
||||
/>
|
||||
|
||||
### 外部标签
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-external-label"
|
||||
/>
|
||||
|
||||
### 带描述
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-with-description"
|
||||
/>
|
||||
|
||||
### 默认选中
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-default-selected"
|
||||
/>
|
||||
|
||||
### 无效状态
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-invalid"
|
||||
/>
|
||||
|
||||
### 受控组件
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-controlled"
|
||||
/>
|
||||
|
||||
### 半选状态
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-indeterminate"
|
||||
/>
|
||||
|
||||
### 表单集成
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-form"
|
||||
/>
|
||||
|
||||
### 渲染属性
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-render-props"
|
||||
/>
|
||||
|
||||
### 渲染函数
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-render-function"
|
||||
/>
|
||||
|
||||
### 自定义指示器
|
||||
|
||||
<ComponentPreview
|
||||
name="checkbox-custom-indicator"
|
||||
/>
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="checkbox-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
可使用 `@layer components` 指令自定义 Checkbox 组件类。
|
||||
[了解更多](https://tailwindcss.com/docs/adding-custom-styles#adding-component-classes)。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-checkbox {
|
||||
@apply inline-flex gap-3 items-center;
|
||||
}
|
||||
|
||||
.hv-checkbox__control {
|
||||
@apply size-5 border-2 border-gray-400 rounded data-[selected=true]:bg-blue-500 data-[selected=true]:border-blue-500;
|
||||
|
||||
/* Animated background indicator */
|
||||
&::before {
|
||||
@apply bg-accent pointer-events-none absolute inset-0 z-0 origin-center scale-50 rounded-md opacity-0 content-[''];
|
||||
|
||||
transition:
|
||||
scale 200ms linear,
|
||||
opacity 200ms linear,
|
||||
background-color 200ms ease-out;
|
||||
}
|
||||
|
||||
/* Show indicator when selected */
|
||||
&[data-selected="true"]::before {
|
||||
@apply scale-100 opacity-100;
|
||||
}
|
||||
}
|
||||
|
||||
.hv-checkbox__indicator {
|
||||
@apply text-white;
|
||||
}
|
||||
|
||||
.hv-checkbox__content {
|
||||
@apply items-center gap-3;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
|
||||
|
||||
### CSS 类
|
||||
|
||||
Checkbox 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/checkbox.css)):
|
||||
|
||||
#### 基础类
|
||||
|
||||
- `.hv-checkbox` - 基础复选框容器(字段)
|
||||
- `.hv-checkbox__content` - 包裹控件与标签文本的可点击 label
|
||||
- `.hv-checkbox__control` - 复选框控件框
|
||||
- `.hv-checkbox__indicator` - 复选框勾选指示器
|
||||
|
||||
### 交互状态
|
||||
|
||||
复选框同时支持 CSS 伪类与 data 属性:
|
||||
|
||||
- **Selected**:`[data-selected="true"]` 或 `[aria-checked="true"]`(显示勾选与背景色变化)
|
||||
- **Indeterminate**:`[data-indeterminate="true"]`(显示不确定状态的短横线)
|
||||
- **Invalid**:`[data-invalid="true"]` 或 `[aria-invalid="true"]`(显示 danger 色错误状态)
|
||||
- **Hover**:`CheckboxContent`(可点击标签)上的 `:hover` 或 `[data-hovered="true"]`
|
||||
- **Focus**:按钮上的 `:focus-visible` 或 `[data-focus-visible="true"]`(控件上显示焦点环)
|
||||
- **Disabled**:字段上的 `[data-disabled="true"]`(降低透明度,包括帮助文本)
|
||||
- **Pressed**:`:active` 或 `[data-pressed="true"]`
|
||||
|
||||
## API 参考
|
||||
|
||||
本库采用原生 label/input 承载选择与提交,复用共享字段、Form、Fieldset 禁用和错误协议。原生输入是唯一的提交值来源;组内没有 Reka 的重复隐藏值或带索引字段名。组校验另有无 name、不可 Tab 聚焦的约束代理,不产生 FormData 条目。
|
||||
|
||||
### Checkbox
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| ------------------------------------ | --------------------------------------------------------------------- | -------------------------- | ----------------------------------------------------------------------- |
|
||||
| `checked` | `boolean` | 非受控 | 当前选择,推荐 `v-model:checked` |
|
||||
| `isSelected` | `boolean` | - | 保留上游受控属性,支持 `v-model:isSelected`;同时传值时 checked 优先 |
|
||||
| `defaultChecked` / `defaultSelected` | `boolean` | `false` | 非受控初始值;defaultChecked 优先 |
|
||||
| `isIndeterminate` | `boolean` | `false` | 独立的半选外观;不将 mixed 字符串提交。点击后是否解除由调用方更新该属性 |
|
||||
| `value` | `string` | `'on'` | 原生提交值;组内应显式指定唯一 value |
|
||||
| `name` / `form` / `id` | `string` | - / - / 自动 | 落在真实 checkbox;组内 name/form 由组统一管理 |
|
||||
| `variant` | `'primary' \| 'secondary'` | 继承组,否则 primary | 显式子变体优先 |
|
||||
| `isDisabled` / `disabled` | `boolean` | `false` | 禁用,不能解除组/Fieldset 禁用 |
|
||||
| `isReadOnly` | `boolean` | `false` | 保持可聚焦,阻止鼠标和键盘更新 |
|
||||
| `isRequired` / `isInvalid` | `boolean` | `false` | 必填约束 / 纯展示错误状态;后者不单独阻止提交 |
|
||||
| `validate` | `(value: boolean) => string \| string[] \| true \| null \| undefined` | - | 同步校验 |
|
||||
| `validationBehavior` | `'native' \| 'aria'` | 继承组或 Form,否则 native | native 拦截;aria 只显示语义 |
|
||||
| `class` / `style` | Vue class/style 绑定 | - | 字段容器;ARIA 和 DOM 监听落在真实 input |
|
||||
| 默认插槽 | 作用域插槽 | 默认 control/indicator | 字段部件与状态 |
|
||||
|
||||
### 事件与暴露
|
||||
|
||||
| 接口 | 参数 / 行为 |
|
||||
| ------------------------------------------------- | -------------------------------------------------------- |
|
||||
| `update:checked` / `update:isSelected` / `change` | 每次修改请求发出 boolean;受控拒绝后恢复原生 checked |
|
||||
| `focus()` / `element` | 模板 ref 暴露;实际 HTMLInputElement(公开实例自动解包) |
|
||||
|
||||
默认控件空内容时需提供 aria-label;推荐显式组合 Content 与文案。原生 Space 切换;外部 Label 的 for 与 Checkbox id 对应真实输入。禁用项不提交,未选中项不提交,非受控 reset 恢复初始值;取消 reset 保留当前值。
|
||||
|
||||
### CheckboxContent / Control / Indicator
|
||||
|
||||
| 部件 | 根与插槽 | 属性落点 |
|
||||
| --------- | ------------------------------------------ | ------------------------------------------ |
|
||||
| Content | 原生 label,包含实际 input;默认作用域插槽 | class/style/原生 label 属性及事件 |
|
||||
| Control | span,默认插槽 | class/style/DOM 属性与事件 |
|
||||
| Indicator | span,默认作用域插槽 | 装饰 aria-hidden;自定义内容替换基线指示器 |
|
||||
|
||||
具名导出使用 CheckboxContent、CheckboxControl、CheckboxIndicator;不使用 React 对象式子部件。class 均支持字符串、数组和对象。默认图形精确来自基线,文档自定义图标使用 Tabler。Content 输出 selected/indeterminate/hovered/pressed/focus-visible 状态标记供定制样式使用。
|
||||
|
||||
### 作用域插槽状态
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| ---------------------------------------------------------- | --------- | ------------------------------ |
|
||||
| `isSelected` / `isIndeterminate` | `boolean` | 选中 / 半选(半选仅 Checkbox) |
|
||||
| `isDisabled` / `isReadOnly` / `isRequired` / `isInvalid` | `boolean` | 当前状态 |
|
||||
| `isHovered` / `isPressed` / `isFocused` / `isFocusVisible` | `boolean` | 单成员交互状态 |
|
||||
|
||||
组作用域提供 value、validationErrors、isDisabled/isReadOnly/isRequired/isInvalid,以及 state.value/state.setValue;单成员另提供 state.isSelected/state.setSelected/state.toggle。不把组值和单成员状态混用。
|
||||
|
||||
### 框架适配与边界
|
||||
|
||||
render 自定义根类型未支持;基线 div+data-custom 示例以 Vue 根属性透传保留效果。SSR 预规划直接/原生/Fragment 包裹的标签、说明、错误与直接成员;本库 Content 内的说明也支持。任意用户 Vue 包装组件无法静态展开,需要显式 aria-labelledby/aria-describedby 和 ID 保证首屏关联。没有宣称完整读屏、触屏、Nuxt 或逐像素验收。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Checkbox](./checkbox) · [CheckboxGroup](./checkbox-group) · [RadioGroup](./radio-group) · [Fieldset](./fieldset)
|
||||
@@ -0,0 +1,272 @@
|
||||
---
|
||||
title: RadioGroup 单选框组
|
||||
description: 用于从列表中选择单个选项的单选组。
|
||||
icon: updated
|
||||
component: radio-group
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Radio,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Label,
|
||||
Description,
|
||||
FieldError,
|
||||
RadioGroup,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview
|
||||
name="radio-group-basic"
|
||||
/>
|
||||
|
||||
## 组件结构
|
||||
|
||||
使用 RadioGroup、Radio、RadioContent、RadioControl 和 RadioIndicator 具名导出组合。
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Radio,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Label,
|
||||
Description,
|
||||
FieldError,
|
||||
RadioGroup,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RadioGroup>
|
||||
<Label>选择选项</Label>
|
||||
<Radio value="basic">
|
||||
<RadioContent>
|
||||
<RadioControl><RadioIndicator /></RadioControl>
|
||||
<Label>选项</Label>
|
||||
</RadioContent>
|
||||
<Description />
|
||||
</Radio>
|
||||
<FieldError />
|
||||
</RadioGroup>
|
||||
</template>
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### 水平排列
|
||||
|
||||
<ComponentPreview
|
||||
name="radio-group-horizontal"
|
||||
/>
|
||||
|
||||
### 变体
|
||||
|
||||
RadioGroup 组件支持两种视觉变体:
|
||||
|
||||
- **`primary`**(默认)— 带默认背景的标准样式,适用于大多数场景
|
||||
- **`secondary`** — 低强调变体,适合在 Surface 等表面背景上使用
|
||||
|
||||
<ComponentPreview name="radio-group-variants" />
|
||||
|
||||
### 表面样式
|
||||
|
||||
在 [Surface](/components/surface) 内使用时,请使用 `variant="secondary"`,以应用适合表面背景的低强调变体。
|
||||
|
||||
<ComponentPreview
|
||||
name="radio-group-on-surface"
|
||||
/>
|
||||
|
||||
### 禁用
|
||||
|
||||
<ComponentPreview
|
||||
name="radio-group-disabled"
|
||||
/>
|
||||
|
||||
### 受控组件
|
||||
|
||||
<ComponentPreview
|
||||
name="radio-group-controlled"
|
||||
/>
|
||||
|
||||
### 非受控
|
||||
|
||||
仅需响应更新时,将 `defaultValue` 与 `update:modelValue` 配合使用。
|
||||
|
||||
<ComponentPreview
|
||||
name="radio-group-uncontrolled"
|
||||
/>
|
||||
|
||||
### 表单校验
|
||||
|
||||
<ComponentPreview
|
||||
name="radio-group-validation"
|
||||
/>
|
||||
|
||||
### 配送与支付
|
||||
|
||||
<ComponentPreview
|
||||
isBgSolid
|
||||
align="start"
|
||||
name="radio-group-delivery-and-payment"
|
||||
/>
|
||||
|
||||
### 自定义指示器
|
||||
|
||||
<ComponentPreview
|
||||
name="radio-group-custom-indicator"
|
||||
/>
|
||||
|
||||
### 渲染函数
|
||||
|
||||
<ComponentPreview
|
||||
name="radio-group-render-function"
|
||||
/>
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="radio-group-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
若要自定义组件类,可使用 `@layer components` 指令。[了解更多](https://tailwindcss.com/docs/adding-custom-styles#adding-component-classes)。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-radio-group {
|
||||
@apply gap-2;
|
||||
}
|
||||
|
||||
.hv-radio {
|
||||
@apply gap-4 rounded-lg border border-border p-3 hover:bg-surface-hovered;
|
||||
}
|
||||
|
||||
.hv-radio__control {
|
||||
@apply border-2 border-accent;
|
||||
}
|
||||
|
||||
.hv-radio__indicator {
|
||||
@apply bg-primary;
|
||||
}
|
||||
|
||||
.hv-radio__content {
|
||||
@apply gap-1;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
|
||||
|
||||
### CSS 类
|
||||
|
||||
RadioGroup 使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/radio-group.css)):
|
||||
|
||||
#### 基础类
|
||||
|
||||
- `.hv-radio-group` - 单选组基础容器
|
||||
- `.hv-radio` - 单个单选项
|
||||
- `.hv-radio__control` - 单选控件(圆形按钮)
|
||||
- `.hv-radio__indicator` - 单选指示器(内部圆点)
|
||||
- `.hv-radio__content` - 单选内容包裹层
|
||||
|
||||
#### 修饰类
|
||||
|
||||
禁用态通过 `.hv-radio` 上的 `[data-disabled="true"]` / `[aria-disabled="true"]`(以及 `:disabled`)应用——没有 `.hv-radio--disabled` 修饰类。
|
||||
|
||||
### 交互状态
|
||||
|
||||
单选项同时支持 CSS 伪类与 data 属性,便于灵活定制:
|
||||
|
||||
- **Selected**:`[aria-checked="true"]` 或 `[data-selected="true"]`(显示指示器)
|
||||
- **Hover**:`:hover` 或 `[data-hovered="true"]`(边框颜色变化)
|
||||
- **Focus**:`:focus-visible` 或 `[data-focus-visible="true"]`(显示焦点环)
|
||||
- **Pressed**:`:active` 或 `[data-pressed="true"]`(缩放变换)
|
||||
- **Disabled**:`:disabled` 或 `[aria-disabled="true"]`(降低透明度并禁用指针事件)
|
||||
- **Invalid**:`[data-invalid="true"]` 或 `[aria-invalid="true"]`(错误边框颜色)
|
||||
|
||||
## API 参考
|
||||
|
||||
本库采用原生 label/input 承载选择与提交,复用共享字段、Form、Fieldset 禁用和错误协议。原生输入是唯一的提交值来源;组内没有 Reka 的重复隐藏值或带索引字段名。组校验另有无 name、不可 Tab 聚焦的约束代理,不产生 FormData 条目。
|
||||
|
||||
### RadioGroup
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| -------------------------- | --------------------------------------------------------------------------------- | ---------------------- | -------------------------------------- |
|
||||
| `modelValue` | `string \| undefined` | 非受控 | 当前值,使用 v-model |
|
||||
| `defaultValue` | `string \| undefined` | `undefined` | 非受控初始值副本 |
|
||||
| `name` / `form` / `id` | `string` | - / - / 自动 | 统一原生提交键、表单归属及组 ID |
|
||||
| `variant` | `'primary' \| 'secondary'` | `'primary'` | 组视觉样式;Checkbox 成员可显式覆盖 |
|
||||
| `isDisabled` / `disabled` | `boolean` | `false` | 合并 Fieldset 禁用,后代不能解除 |
|
||||
| `isReadOnly` | `boolean` | `false` | 阻止成员点击、空格和方向键修改 |
|
||||
| `isRequired` / `isInvalid` | `boolean` | `false` | 要求至少一项可用选择 / 错误展示 |
|
||||
| `validate` | `(value: string \| undefined) => string \| string[] \| true \| null \| undefined` | - | 同步组校验 |
|
||||
| `validationBehavior` | `'native' \| 'aria'` | 继承 Form,否则 native | 原生提交拦截或仅错误语义 |
|
||||
| `class` / `style` | Vue class/style 绑定 | - | 合并根样式,接受字符串/数组/对象 class |
|
||||
| 默认插槽 | 作用域插槽 | - | 标签、说明、成员、错误 |
|
||||
| `orientation` | `'vertical' \| 'horizontal'` | `'vertical'` | 布局及 aria-orientation |
|
||||
| `dir` / `loop` | `'ltr' \| 'rtl'` / `boolean` | 继承方向 / `true` | 方向键映射及循环 |
|
||||
|
||||
### Radio
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| ------------------------------------------------------ | -------------------- | ------- | --------------------------- |
|
||||
| `value` | `string` | 必填 | 组内唯一值 |
|
||||
| `id` | `string` | 自动 | 实际 radio ID |
|
||||
| `isDisabled` / `disabled` / `isReadOnly` / `isInvalid` | `boolean` | `false` | 成员状态,与组状态合并 |
|
||||
| `class` / `style` | Vue class/style 绑定 | - | 字段根;ARIA/事件落在 input |
|
||||
| `name` / `form` | `string` | - | 组内统一由 RadioGroup 管理 |
|
||||
|
||||
Radio 必须在 RadioGroup 中使用。不为未选中的 Radio 输出 data-selected;默认 Indicator 保持 CSS :empty 内圆点。Tab 进入选中可用成员或首个可用成员;方向键跳过禁用项,支持 RTL、Home/End,且调用者 keydown.prevent 可以取消。
|
||||
|
||||
### 事件与暴露
|
||||
|
||||
| 接口 | 行为 |
|
||||
| ------------------------------ | ---------------------------------------------------------------------- |
|
||||
| `update:modelValue` / `change` | 发出新的数组或标量;不修改传入数组;父级拒绝后恢复所有原生 checked |
|
||||
| `focus()` / `element` | 聚焦选中可用成员或首个可用成员;空组聚焦组根。element 是组 HTMLElement |
|
||||
|
||||
CheckboxGroup 按原生约定提交同名重复条目,通过 FormData.getAll(name) 获取;RadioGroup 只提交一个选中可用值。未指定 name 不产生提交值。每个成员 value 必须唯一;重复或动态改成重复值会抛出明确错误。不为移除的选择自动选择别的成员;模型保留调用者的值,FormData 只包含实际存在的可用成员。
|
||||
|
||||
required 检查整个组,不能让每个 Checkbox 都变成必选;native 无效提交聚焦第一个可用成员,空组聚焦根。只读保留提交值并跳过必填/自定义约束。reset 尊重 preventDefault,受控值不覆盖,非受控恢复初始副本。动态 name/form 会更新提交和 reset 归属。
|
||||
|
||||
Label 在组中渲染 span 并注册 aria-labelledby;不要手写 for 指向组 div。每个成员独立隔离 Description/FieldError,同时合并组描述和当前组错误。后端错误使用 Form.validationErrors 按 name 映射,编辑后忽略当前响应,新对象可恢复错误。暂不提供异步 validate 或完整 validationDetails。
|
||||
|
||||
### RadioContent / Control / Indicator
|
||||
|
||||
| 部件 | 根与插槽 | 属性落点 |
|
||||
| --------- | ------------------------------------------ | ------------------------------------------ |
|
||||
| Content | 原生 label,包含实际 input;默认作用域插槽 | class/style/原生 label 属性及事件 |
|
||||
| Control | span,默认插槽 | class/style/DOM 属性与事件 |
|
||||
| Indicator | span,默认作用域插槽 | 装饰 aria-hidden;自定义内容替换基线指示器 |
|
||||
|
||||
具名导出使用 RadioContent、RadioControl、RadioIndicator;不使用 React 对象式子部件。class 均支持字符串、数组和对象。默认图形精确来自基线,文档自定义图标使用 Tabler。Content 输出 selected/indeterminate/hovered/pressed/focus-visible 状态标记供定制样式使用。
|
||||
|
||||
### 作用域插槽状态
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| ---------------------------------------------------------- | --------- | ------------------------------ |
|
||||
| `isSelected` / `isIndeterminate` | `boolean` | 选中 / 半选(半选仅 Checkbox) |
|
||||
| `isDisabled` / `isReadOnly` / `isRequired` / `isInvalid` | `boolean` | 当前状态 |
|
||||
| `isHovered` / `isPressed` / `isFocused` / `isFocusVisible` | `boolean` | 单成员交互状态 |
|
||||
|
||||
组作用域提供 value、validationErrors、isDisabled/isReadOnly/isRequired/isInvalid,以及 state.value/state.setValue;单成员另提供 state.isSelected/state.setSelected/state.toggle。不把组值和单成员状态混用。
|
||||
|
||||
### 框架适配与边界
|
||||
|
||||
render 自定义根类型未支持;基线 div+data-custom 示例以 Vue 根属性透传保留效果。SSR 预规划直接/原生/Fragment 包裹的标签、说明、错误与直接成员;本库 Content 内的说明也支持。任意用户 Vue 包装组件无法静态展开,需要显式 aria-labelledby/aria-describedby 和 ID 保证首屏关联。没有宣称完整读屏、触屏、Nuxt 或逐像素验收。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Checkbox](./checkbox) · [CheckboxGroup](./checkbox-group) · [RadioGroup](./radio-group) · [Fieldset](./fieldset)
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Checkbox name="basic-terms">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
接受条款与条件
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</template>
|
||||
@@ -0,0 +1,30 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const isSelected = ref(true);
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-3">
|
||||
<Checkbox
|
||||
id="email-notifications"
|
||||
:is-selected="isSelected"
|
||||
@update:checked="isSelected = $event"
|
||||
>
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
邮件通知
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<p class="text-sm text-muted">
|
||||
状态:
|
||||
<span class="font-medium">{{ isSelected ? "已勾选" : "未勾选" }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconHeartFilled, IconPlus, IconMinus } from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex gap-4">
|
||||
<Checkbox default-selected name="heart">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator v-slot="{ isSelected }">
|
||||
<IconHeartFilled v-if="isSelected" aria-hidden="true" />
|
||||
</CheckboxIndicator>
|
||||
</CheckboxControl>
|
||||
心形
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox default-selected name="plus">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator v-slot="{ isSelected }">
|
||||
<IconPlus v-if="isSelected" aria-hidden="true" />
|
||||
</CheckboxIndicator>
|
||||
</CheckboxControl>
|
||||
加号
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox is-indeterminate name="indeterminate">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator v-slot="{ isIndeterminate }">
|
||||
<IconMinus v-if="isIndeterminate" aria-hidden="true" />
|
||||
</CheckboxIndicator>
|
||||
</CheckboxControl>
|
||||
部分选中
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Checkbox id="custom">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl class="bg-success-soft before:bg-success">
|
||||
<CheckboxIndicator
|
||||
class="**:data-[slot=checkbox-default-indicator--checkmark]:text-success-foreground"
|
||||
/>
|
||||
</CheckboxControl>
|
||||
自定义样式复选框
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Checkbox default-selected id="default-notifications">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
启用邮件通知
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Checkbox is-disabled id="feature">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
高级功能
|
||||
</CheckboxContent>
|
||||
<Description>该功能即将推出</Description>
|
||||
</Checkbox>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-3">
|
||||
<Checkbox id="label-marketing">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Label for="label-marketing">给我发送营销邮件</Label>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const result = ref("");
|
||||
function submit(event: Event) {
|
||||
const data = new FormData(event.currentTarget as HTMLFormElement);
|
||||
result.value =
|
||||
"表单提交数据:\n" +
|
||||
Array.from(data)
|
||||
.map(([key, value]) => `${key}: ${value}`)
|
||||
.join("\n");
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<form class="flex flex-col gap-4" @submit.prevent="submit">
|
||||
<div class="flex flex-col gap-3">
|
||||
<Checkbox name="notifications" value="on">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
启用通知
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox default-selected name="newsletter" value="on">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
订阅新闻通讯
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox name="marketing" value="on">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
接收营销更新
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</div>
|
||||
<Button class="mt-4" size="sm" type="submit" variant="primary">提交</Button>
|
||||
<pre v-if="result" role="status" class="whitespace-pre-wrap text-sm">{{
|
||||
result
|
||||
}}</pre>
|
||||
</form>
|
||||
</template>
|
||||
@@ -0,0 +1,60 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-6">
|
||||
<div class="flex flex-col gap-3">
|
||||
<Label class="text-muted">圆角复选框</Label>
|
||||
<Checkbox
|
||||
class="[&_[data-slot='checkbox-default-indicator--checkmark']]:size-2"
|
||||
name="small-rounded"
|
||||
>
|
||||
<CheckboxContent>
|
||||
<CheckboxControl class="size-3 rounded-full before:rounded-full">
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
小尺寸
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</div>
|
||||
<div class="flex flex-col gap-3">
|
||||
<Checkbox name="default-rounded">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl class="size-4 rounded-full before:rounded-full">
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
默认尺寸
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</div>
|
||||
<div class="flex flex-col gap-3">
|
||||
<Checkbox name="large-rounded">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl class="size-5 rounded-full before:rounded-full">
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
大尺寸
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</div>
|
||||
<div class="flex flex-col gap-3">
|
||||
<Checkbox
|
||||
class="[&_[data-slot='checkbox-default-indicator--checkmark']]:size-4"
|
||||
name="xl-rounded"
|
||||
>
|
||||
<CheckboxContent>
|
||||
<CheckboxControl class="size-6 rounded-full before:rounded-full">
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
特大尺寸
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxGroup,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<CheckboxGroup name="interests">
|
||||
<Label>选择你的兴趣</Label>
|
||||
<Description>可多选</Description>
|
||||
<Checkbox value="coding">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
编程
|
||||
</CheckboxContent>
|
||||
<Description>热爱构建软件</Description>
|
||||
</Checkbox>
|
||||
<Checkbox value="design">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
设计
|
||||
</CheckboxContent>
|
||||
<Description>喜欢打造精美界面</Description>
|
||||
</Checkbox>
|
||||
<Checkbox value="writing">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
写作
|
||||
</CheckboxContent>
|
||||
<Description>热衷于内容创作</Description>
|
||||
</Checkbox>
|
||||
</CheckboxGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,49 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxGroup,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const selected = ref(["coding", "design"]);
|
||||
</script>
|
||||
<template>
|
||||
<CheckboxGroup
|
||||
class="min-w-[320px]"
|
||||
name="skills"
|
||||
:model-value="selected"
|
||||
@update:model-value="selected = $event"
|
||||
>
|
||||
<Label>你的技能</Label>
|
||||
<Checkbox value="coding">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
编程
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox value="design">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
设计
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox value="writing">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
写作
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Label class="my-4 text-sm text-muted">
|
||||
已选:{{ selected.join(", ") || "无" }}
|
||||
</Label>
|
||||
</CheckboxGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxGroup,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
const controlClassName = "bg-success-soft before:bg-success";
|
||||
const indicatorClassName =
|
||||
"**:data-[slot=checkbox-default-indicator--checkmark]:text-success-foreground";
|
||||
const channels = [
|
||||
{ label: "电子邮件", value: "email" },
|
||||
{ label: "短信", value: "sms" },
|
||||
{ label: "推送", value: "push" },
|
||||
] as const;
|
||||
</script>
|
||||
<template>
|
||||
<CheckboxGroup
|
||||
class="gap-3 **:data-[slot=checkbox]:mt-0"
|
||||
:default-value="['email']"
|
||||
name="notification-channels"
|
||||
>
|
||||
<Label>通知渠道</Label>
|
||||
<Description>选择我们通过何种方式向您发送账户更新。</Description>
|
||||
<Checkbox v-for="{ label, value } in channels" :key="value" :value="value">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl :class="controlClassName">
|
||||
<CheckboxIndicator :class="indicatorClassName" />
|
||||
</CheckboxControl>
|
||||
{{ label }}
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</CheckboxGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,35 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxGroup,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<CheckboxGroup is-disabled name="disabled-features">
|
||||
<Label>功能</Label>
|
||||
<Description>功能选择暂时不可用</Description>
|
||||
<Checkbox value="feature1">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
功能一
|
||||
</CheckboxContent>
|
||||
<Description>该功能即将推出</Description>
|
||||
</Checkbox>
|
||||
<Checkbox value="feature2">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
功能二
|
||||
</CheckboxContent>
|
||||
<Description>该功能即将推出</Description>
|
||||
</Checkbox>
|
||||
</CheckboxGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,69 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxGroup,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconMail, IconMessage, IconBell } from "@tabler/icons-vue";
|
||||
const addOns = [
|
||||
{
|
||||
description: "通过邮件接收更新",
|
||||
icon: IconMail,
|
||||
title: "邮件通知",
|
||||
value: "email",
|
||||
},
|
||||
{
|
||||
description: "即时短信通知",
|
||||
icon: IconMessage,
|
||||
title: "短信提醒",
|
||||
value: "sms",
|
||||
},
|
||||
{
|
||||
description: "浏览器与移动端推送提醒",
|
||||
icon: IconBell,
|
||||
title: "推送通知",
|
||||
value: "push",
|
||||
},
|
||||
];
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex w-full flex-col items-center gap-10 px-4 py-8">
|
||||
<section class="flex w-full min-w-[320px] max-sm:min-w-0 flex-col gap-4">
|
||||
<CheckboxGroup name="notification-preferences">
|
||||
<Label>通知偏好</Label>
|
||||
<Description>选择接收更新的方式</Description>
|
||||
<div class="flex flex-col gap-2">
|
||||
<Checkbox
|
||||
v-for="addon in addOns"
|
||||
:key="addon.value"
|
||||
:value="addon.value"
|
||||
variant="secondary"
|
||||
>
|
||||
<CheckboxContent
|
||||
class="group relative flex w-full flex-row items-start justify-start gap-4 rounded-3xl bg-surface px-5 py-4 transition-all data-[selected=true]:bg-accent/10"
|
||||
>
|
||||
<CheckboxControl
|
||||
class="absolute end-4 top-3 size-5 rounded-full before:rounded-full"
|
||||
>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
<component
|
||||
:is="addon.icon"
|
||||
class="size-5 text-accent-soft-foreground"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<div class="flex flex-col gap-1">
|
||||
<span>{{ addon.title }}</span>
|
||||
<Description>{{ addon.description }}</Description>
|
||||
</div>
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</div>
|
||||
</CheckboxGroup>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,57 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxGroup,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const selected = ref(["coding"]);
|
||||
const allOptions = ["coding", "design", "writing"];
|
||||
</script>
|
||||
<template>
|
||||
<div>
|
||||
<Checkbox
|
||||
:is-indeterminate="
|
||||
selected.length > 0 && selected.length < allOptions.length
|
||||
"
|
||||
:checked="selected.length === allOptions.length"
|
||||
name="select-all"
|
||||
@update:checked="selected = $event ? [...allOptions] : []"
|
||||
>
|
||||
<CheckboxContent>
|
||||
<CheckboxControl><CheckboxIndicator /></CheckboxControl>
|
||||
全选
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<div class="ms-6 flex flex-col gap-2">
|
||||
<CheckboxGroup v-model="selected">
|
||||
<Checkbox value="coding">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
编程
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox value="design">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
设计
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox value="writing">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
写作
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</CheckboxGroup>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,47 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxGroup,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Label,
|
||||
Description,
|
||||
Surface,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Surface class="w-full rounded-3xl p-6">
|
||||
<CheckboxGroup name="interests" variant="secondary">
|
||||
<Label>选择你的兴趣</Label>
|
||||
<Description>可多选</Description>
|
||||
<Checkbox value="coding">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
编程
|
||||
</CheckboxContent>
|
||||
<Description>热爱构建软件</Description>
|
||||
</Checkbox>
|
||||
<Checkbox value="design">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
设计
|
||||
</CheckboxContent>
|
||||
<Description>喜欢打造精美界面</Description>
|
||||
</Checkbox>
|
||||
<Checkbox value="writing">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
写作
|
||||
</CheckboxContent>
|
||||
<Description>热衷于内容创作</Description>
|
||||
</Checkbox>
|
||||
</CheckboxGroup>
|
||||
</Surface>
|
||||
</template>
|
||||
@@ -0,0 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxGroup,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<CheckboxGroup name="interests" data-custom="foo">
|
||||
<Label>选择你的兴趣</Label>
|
||||
<Description>可多选</Description>
|
||||
<Checkbox value="coding">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
编程
|
||||
</CheckboxContent>
|
||||
<Description>热爱构建软件</Description>
|
||||
</Checkbox>
|
||||
<Checkbox value="design">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
设计
|
||||
</CheckboxContent>
|
||||
<Description>喜欢打造精美界面</Description>
|
||||
</Checkbox>
|
||||
<Checkbox value="writing">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
写作
|
||||
</CheckboxContent>
|
||||
<Description>热衷于内容创作</Description>
|
||||
</Checkbox>
|
||||
</CheckboxGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxGroup,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Label,
|
||||
FieldError,
|
||||
Button,
|
||||
Form,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const result = ref("");
|
||||
function submit(event: Event) {
|
||||
const data = new FormData(event.currentTarget as HTMLFormElement);
|
||||
result.value = "已选偏好:" + data.getAll("preferences").join(", ");
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Form class="flex flex-col gap-4 px-4" @submit.prevent="submit">
|
||||
<CheckboxGroup is-required name="preferences">
|
||||
<Label>偏好设置</Label>
|
||||
<Checkbox value="email">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
邮件通知
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox value="sms">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
短信通知
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox value="push">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
推送通知
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<FieldError>请至少选择一种通知方式。</FieldError>
|
||||
</CheckboxGroup>
|
||||
<Button type="submit">提交</Button>
|
||||
<p v-if="result" role="status" class="text-sm">{{ result }}</p>
|
||||
</Form>
|
||||
</template>
|
||||
@@ -0,0 +1,40 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxGroup,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconX } from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<CheckboxGroup name="features">
|
||||
<Label>功能</Label>
|
||||
<Description>选择你需要的功能</Description>
|
||||
<Checkbox value="notifications">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator v-slot="{ isSelected }">
|
||||
<IconX v-if="isSelected" aria-hidden="true" />
|
||||
</CheckboxIndicator>
|
||||
</CheckboxControl>
|
||||
邮件通知
|
||||
</CheckboxContent>
|
||||
<Description>通过邮件接收更新</Description>
|
||||
</Checkbox>
|
||||
<Checkbox value="newsletter">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator v-slot="{ isSelected }">
|
||||
<IconX v-if="isSelected" aria-hidden="true" />
|
||||
</CheckboxIndicator>
|
||||
</CheckboxControl>
|
||||
邮件通讯
|
||||
</CheckboxContent>
|
||||
<Description>每周接收邮件简报</Description>
|
||||
</Checkbox>
|
||||
</CheckboxGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,30 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Checkbox,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
const isIndeterminate = ref(true),
|
||||
isSelected = ref(false);
|
||||
function update(value: boolean) {
|
||||
isSelected.value = value;
|
||||
isIndeterminate.value = false;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Checkbox
|
||||
id="select-all"
|
||||
:is-indeterminate="isIndeterminate"
|
||||
:checked="isSelected"
|
||||
@update:checked="update"
|
||||
>
|
||||
<CheckboxContent>
|
||||
<CheckboxControl><CheckboxIndicator /></CheckboxControl>
|
||||
全选
|
||||
</CheckboxContent>
|
||||
<Description>展示部分选中状态(短横线图标)</Description>
|
||||
</Checkbox>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
FieldError,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Checkbox is-invalid is-required name="agreement">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
我同意条款
|
||||
</CheckboxContent>
|
||||
<FieldError>您必须接受条款才能继续</FieldError>
|
||||
</Checkbox>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Checkbox data-custom="bar">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
接受条款与条件
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Checkbox id="render-props-terms" v-slot="{ isSelected }">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl><CheckboxIndicator /></CheckboxControl>
|
||||
{{ isSelected ? "已同意条款" : "接受条款" }}
|
||||
</CheckboxContent>
|
||||
<Description>
|
||||
{{ isSelected ? "感谢您的确认" : "请先阅读并接受条款" }}
|
||||
</Description>
|
||||
</Checkbox>
|
||||
</template>
|
||||
@@ -0,0 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm font-medium text-muted">主要变体</p>
|
||||
<Checkbox id="primary" name="primary" variant="primary">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
主要复选框
|
||||
</CheckboxContent>
|
||||
<Description>默认背景的标准样式</Description>
|
||||
</Checkbox>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm font-medium text-muted">次要变体</p>
|
||||
<Checkbox id="secondary" name="secondary" variant="secondary">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
次要复选框
|
||||
</CheckboxContent>
|
||||
<Description>用于表面容器的低强调样式</Description>
|
||||
</Checkbox>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Checkbox name="description-notifications">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
邮件通知
|
||||
</CheckboxContent>
|
||||
<Description>当有人在评论中提及您时收到通知</Description>
|
||||
</Checkbox>
|
||||
</template>
|
||||
@@ -0,0 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
RadioGroup,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Radio,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<RadioGroup default-value="premium" name="plan">
|
||||
<Label>选择套餐</Label>
|
||||
<Description>选择最适合你的套餐</Description>
|
||||
<Radio value="basic">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
基础版
|
||||
</RadioContent>
|
||||
<Description>每月包含 100 条消息</Description>
|
||||
</Radio>
|
||||
<Radio value="premium">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
高级版
|
||||
</RadioContent>
|
||||
<Description>每月包含 200 条消息</Description>
|
||||
</Radio>
|
||||
<Radio value="business">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
商业版
|
||||
</RadioContent>
|
||||
<Description>无限消息</Description>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,55 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
RadioGroup,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Radio,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const value = ref<string | undefined>("pro");
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<RadioGroup
|
||||
name="plan-controlled"
|
||||
:model-value="value"
|
||||
@update:model-value="value = $event"
|
||||
>
|
||||
<Label>订阅套餐</Label>
|
||||
<Radio value="starter">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
入门版
|
||||
</RadioContent>
|
||||
<Description>适合副项目和小型团队</Description>
|
||||
</Radio>
|
||||
<Radio value="pro">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
专业版
|
||||
</RadioContent>
|
||||
<Description>高级报表与分析</Description>
|
||||
</Radio>
|
||||
<Radio value="teams">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
团队版
|
||||
</RadioContent>
|
||||
<Description>最多可与 10 名队友共享访问权限</Description>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
<p class="text-sm text-muted">
|
||||
已选套餐:
|
||||
<span class="font-medium">{{ value }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,63 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
RadioGroup,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Radio,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconCheck } from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<RadioGroup default-value="premium" name="plan-custom-indicator">
|
||||
<Label>选择套餐</Label>
|
||||
<Description>选择最适合你的套餐</Description>
|
||||
<Radio value="basic">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator v-slot="{ isSelected }">
|
||||
<IconCheck
|
||||
v-if="isSelected"
|
||||
class="size-3 text-background"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</RadioIndicator>
|
||||
</RadioControl>
|
||||
基础版
|
||||
</RadioContent>
|
||||
<Description>每月包含 100 条消息</Description>
|
||||
</Radio>
|
||||
<Radio value="premium">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator v-slot="{ isSelected }">
|
||||
<IconCheck
|
||||
v-if="isSelected"
|
||||
class="size-3 text-background"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</RadioIndicator>
|
||||
</RadioControl>
|
||||
高级版
|
||||
</RadioContent>
|
||||
<Description>每月包含 200 条消息</Description>
|
||||
</Radio>
|
||||
<Radio value="business">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator v-slot="{ isSelected }">
|
||||
<IconCheck
|
||||
v-if="isSelected"
|
||||
class="size-3 text-background"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</RadioIndicator>
|
||||
</RadioControl>
|
||||
商业版
|
||||
</RadioContent>
|
||||
<Description>无限消息</Description>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,55 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
RadioGroup,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Radio,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
const contentClassName =
|
||||
"group flex w-full items-start gap-3 rounded-xl border border-success/10 bg-success-soft/30 px-4 py-3 transition-colors data-[focus-visible=true]:ring-2 data-[focus-visible=true]:ring-success/15 data-[hovered=true]:bg-success-soft-hover data-[selected=true]:border-success/30 data-[selected=true]:bg-success-soft data-[selected=true]:data-[hovered=true]:bg-success-soft-hover";
|
||||
const controlClassName =
|
||||
"mt-0.5 size-5 shrink-0 rounded-full border border-border bg-default shadow-none group-data-[pressed=true]:scale-95 group-data-[selected=true]:border-transparent group-data-[selected=true]:bg-success group-data-[selected=true]:group-data-[pressed=true]:bg-success-hover";
|
||||
const indicatorClassName =
|
||||
"before:rounded-full before:bg-default group-data-[selected=true]:before:scale-50 group-data-[selected=true]:before:bg-success-foreground group-data-[selected=true]:group-data-[pressed=true]:before:scale-[0.57]";
|
||||
const options = [
|
||||
{ description: "每月扣费 $12", label: "按月", value: "monthly" },
|
||||
{ description: "每年一次性扣费 $120", label: "按年", value: "yearly" },
|
||||
] as const;
|
||||
</script>
|
||||
<template>
|
||||
<RadioGroup
|
||||
class="w-full max-w-sm gap-3 **:data-[slot=radio]:mt-0"
|
||||
default-value="yearly"
|
||||
name="billing"
|
||||
variant="secondary"
|
||||
>
|
||||
<Label class="font-medium text-foreground">计费周期</Label>
|
||||
<Description>选择你的扣费频率。</Description>
|
||||
<Radio
|
||||
v-for="{ description, label, value } in options"
|
||||
:key="value"
|
||||
:value="value"
|
||||
>
|
||||
<RadioContent :class="contentClassName">
|
||||
<RadioControl :class="controlClassName">
|
||||
<RadioIndicator :class="indicatorClassName" />
|
||||
</RadioControl>
|
||||
<div class="flex flex-col gap-0.5">
|
||||
<span
|
||||
class="font-medium text-foreground group-data-[selected=true]:text-success-soft-foreground"
|
||||
>
|
||||
{{ label }}
|
||||
</span>
|
||||
<Description
|
||||
class="group-data-[selected=true]:text-success-soft-foreground/80"
|
||||
>
|
||||
{{ description }}
|
||||
</Description>
|
||||
</div>
|
||||
</RadioContent>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,122 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
RadioGroup,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Radio,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconBrandMastercard,
|
||||
IconBrandVisa,
|
||||
IconBrandPaypal,
|
||||
} from "@tabler/icons-vue";
|
||||
const deliveryOptions = [
|
||||
{
|
||||
description: "4–10 个工作日",
|
||||
price: "$5.00",
|
||||
title: "标准",
|
||||
value: "standard",
|
||||
},
|
||||
{
|
||||
description: "2–5 个工作日",
|
||||
price: "$16.00",
|
||||
title: "快递",
|
||||
value: "express",
|
||||
},
|
||||
{
|
||||
description: "1 个工作日",
|
||||
price: "$25.00",
|
||||
title: "极速",
|
||||
value: "super-fast",
|
||||
},
|
||||
];
|
||||
const paymentOptions = [
|
||||
{
|
||||
description: "有效期至 2026/01",
|
||||
icon: IconBrandMastercard,
|
||||
title: "**** 8304",
|
||||
value: "mastercard",
|
||||
},
|
||||
{
|
||||
description: "有效期至 2026/01",
|
||||
icon: IconBrandVisa,
|
||||
title: "**** 0123",
|
||||
value: "visa",
|
||||
},
|
||||
{
|
||||
description: "使用 PayPal 支付",
|
||||
icon: IconBrandPaypal,
|
||||
title: "PayPal",
|
||||
value: "paypal",
|
||||
},
|
||||
];
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
class="flex w-full flex-col items-center gap-10"
|
||||
style="
|
||||
--accent: #006fee;
|
||||
--accent-foreground: #fff;
|
||||
--accent-hover: #006fee;
|
||||
--border-width: 2px;
|
||||
--border-width-field: 2px;
|
||||
--focus: #006fee;
|
||||
"
|
||||
>
|
||||
<section class="flex w-full max-w-lg flex-col gap-4">
|
||||
<RadioGroup default-value="express" name="delivery" variant="secondary">
|
||||
<Label>配送方式</Label>
|
||||
<div class="grid gap-x-4 md:grid-cols-3">
|
||||
<Radio
|
||||
v-for="option in deliveryOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
>
|
||||
<RadioContent
|
||||
class="group relative flex w-full flex-col gap-6 rounded-xl border border-transparent bg-surface px-5 py-4 transition-all data-[selected=true]:border-accent data-[selected=true]:bg-accent/10 data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10"
|
||||
>
|
||||
<RadioControl class="absolute end-4 top-3 size-5">
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
<div class="flex flex-col gap-1">
|
||||
<span>{{ option.title }}</span>
|
||||
<Description>{{ option.description }}</Description>
|
||||
</div>
|
||||
<span class="text-sm font-semibold">{{ option.price }}</span>
|
||||
</RadioContent>
|
||||
</Radio>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</section>
|
||||
<section class="flex w-full max-w-lg flex-col gap-4">
|
||||
<RadioGroup default-value="visa" name="payment" variant="secondary">
|
||||
<div class="flex flex-wrap items-center justify-between gap-4">
|
||||
<Label>支付方式</Label>
|
||||
</div>
|
||||
<div class="grid gap-x-4 md:grid-cols-2">
|
||||
<Radio
|
||||
v-for="option in paymentOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
>
|
||||
<RadioContent
|
||||
class="group relative flex w-full flex-row items-start justify-start gap-4 rounded-xl border border-transparent bg-surface px-5 py-4 transition-all data-[selected=true]:border-accent data-[selected=true]:bg-accent/10"
|
||||
>
|
||||
<RadioControl class="absolute end-4 top-3 size-5">
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
<component :is="option.icon" class="size-6" aria-hidden="true" />
|
||||
<div class="flex flex-col gap-1">
|
||||
<span>{{ option.title }}</span>
|
||||
<Description>{{ option.description }}</Description>
|
||||
</div>
|
||||
</RadioContent>
|
||||
</Radio>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
RadioGroup,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Radio,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<RadioGroup is-disabled default-value="pro" name="plan-disabled">
|
||||
<Label>订阅套餐</Label>
|
||||
<Description>我们正在发布更新,暂时无法更改套餐。</Description>
|
||||
<Radio value="starter">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
入门版
|
||||
</RadioContent>
|
||||
<Description>适合副项目和小型团队</Description>
|
||||
</Radio>
|
||||
<Radio value="pro">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
专业版
|
||||
</RadioContent>
|
||||
<Description>高级报表与分析</Description>
|
||||
</Radio>
|
||||
<Radio value="teams">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
团队版
|
||||
</RadioContent>
|
||||
<Description>最多可与 10 名队友共享访问权限</Description>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,50 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
RadioGroup,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Radio,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<Label id="plan-orientation-label">订阅套餐</Label>
|
||||
<RadioGroup
|
||||
default-value="pro"
|
||||
name="plan-orientation"
|
||||
aria-labelledby="plan-orientation-label"
|
||||
orientation="horizontal"
|
||||
>
|
||||
<Radio value="starter">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
入门版
|
||||
</RadioContent>
|
||||
<Description>适合副项目</Description>
|
||||
</Radio>
|
||||
<Radio value="pro">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
专业版
|
||||
</RadioContent>
|
||||
<Description>高级报表</Description>
|
||||
</Radio>
|
||||
<Radio value="teams">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
团队版
|
||||
</RadioContent>
|
||||
<Description>最多 10 名队友</Description>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,51 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
RadioGroup,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Radio,
|
||||
Label,
|
||||
Description,
|
||||
Surface,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Surface class="w-full rounded-3xl p-6">
|
||||
<RadioGroup
|
||||
default-value="premium"
|
||||
name="plan-on-surface"
|
||||
variant="secondary"
|
||||
>
|
||||
<Label>选择套餐</Label>
|
||||
<Description>选择最适合你的套餐</Description>
|
||||
<Radio value="basic">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
基础版
|
||||
</RadioContent>
|
||||
<Description>每月包含 100 条消息</Description>
|
||||
</Radio>
|
||||
<Radio value="premium">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
高级版
|
||||
</RadioContent>
|
||||
<Description>每月包含 200 条消息</Description>
|
||||
</Radio>
|
||||
<Radio value="business">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
商业版
|
||||
</RadioContent>
|
||||
<Description>无限消息</Description>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
</Surface>
|
||||
</template>
|
||||
@@ -0,0 +1,48 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
RadioGroup,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Radio,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<RadioGroup
|
||||
default-value="premium"
|
||||
name="plan-custom-render"
|
||||
data-custom="foo"
|
||||
>
|
||||
<Label>选择套餐</Label>
|
||||
<Description>选择最适合你的套餐</Description>
|
||||
<Radio value="basic">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
基础版
|
||||
</RadioContent>
|
||||
<Description>每月包含 100 条消息</Description>
|
||||
</Radio>
|
||||
<Radio value="premium">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
高级版
|
||||
</RadioContent>
|
||||
<Description>每月包含 200 条消息</Description>
|
||||
</Radio>
|
||||
<Radio value="business">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
商业版
|
||||
</RadioContent>
|
||||
<Description>无限消息</Description>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,55 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
RadioGroup,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Radio,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const selection = ref<string | undefined>("pro");
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<RadioGroup
|
||||
default-value="pro"
|
||||
name="plan-uncontrolled"
|
||||
@update:model-value="selection = $event"
|
||||
>
|
||||
<Label>订阅套餐</Label>
|
||||
<Radio value="starter">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
入门版
|
||||
</RadioContent>
|
||||
<Description>适合副项目和小型团队</Description>
|
||||
</Radio>
|
||||
<Radio value="pro">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
专业版
|
||||
</RadioContent>
|
||||
<Description>高级报表与分析</Description>
|
||||
</Radio>
|
||||
<Radio value="teams">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
团队版
|
||||
</RadioContent>
|
||||
<Description>最多可与 10 名队友共享访问权限</Description>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
<p class="text-sm text-muted">
|
||||
上次选择的套餐:
|
||||
<span class="font-medium">{{ selection }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,57 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
RadioGroup,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Radio,
|
||||
Label,
|
||||
Description,
|
||||
FieldError,
|
||||
Button,
|
||||
Form,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const result = ref("");
|
||||
function submit(event: Event) {
|
||||
const data = new FormData(event.currentTarget as HTMLFormElement);
|
||||
result.value = "你选择的套餐是: " + data.get("plan-validation");
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Form class="flex flex-col gap-4" @submit.prevent="submit">
|
||||
<RadioGroup is-required name="plan-validation">
|
||||
<Label>订阅套餐</Label>
|
||||
<Radio value="starter">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
入门版
|
||||
</RadioContent>
|
||||
<Description>适合副项目和小型团队</Description>
|
||||
</Radio>
|
||||
<Radio value="pro">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
专业版
|
||||
</RadioContent>
|
||||
<Description>高级报表与分析</Description>
|
||||
</Radio>
|
||||
<Radio value="teams">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
团队版
|
||||
</RadioContent>
|
||||
<Description>最多可与 10 名队友共享访问权限</Description>
|
||||
</Radio>
|
||||
<FieldError>请先选择订阅套餐再继续。</FieldError>
|
||||
</RadioGroup>
|
||||
<Button class="mt-2 w-fit" type="submit">Submit</Button>
|
||||
<p v-if="result" role="status" class="text-sm">{{ result }}</p>
|
||||
</Form>
|
||||
</template>
|
||||
@@ -0,0 +1,64 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
RadioGroup,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioIndicator,
|
||||
Radio,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-8">
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm font-medium text-muted">主要变体</p>
|
||||
<RadioGroup default-value="option1" name="primary-plan" variant="primary">
|
||||
<Radio value="option1">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
选项 1
|
||||
</RadioContent>
|
||||
<Description>默认背景的标准样式</Description>
|
||||
</Radio>
|
||||
<Radio value="option2">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
选项 2
|
||||
</RadioContent>
|
||||
<Description>另一种主要样式选项</Description>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm font-medium text-muted">次要变体</p>
|
||||
<RadioGroup
|
||||
default-value="option1"
|
||||
name="secondary-plan"
|
||||
variant="secondary"
|
||||
>
|
||||
<Radio value="option1">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
选项 1
|
||||
</RadioContent>
|
||||
<Description>用于表面上的低强调变体</Description>
|
||||
</Radio>
|
||||
<Radio value="option2">
|
||||
<RadioContent>
|
||||
<RadioControl>
|
||||
<RadioIndicator />
|
||||
</RadioControl>
|
||||
选项 2
|
||||
</RadioContent>
|
||||
<Description>另一种次要样式选项</Description>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user