+const value = ref(['music'])
+
+const options = [
+ { label: '阅读', value: 'reading' },
+ { label: '音乐', value: 'music' },
+ { label: '运动', value: 'sports' },
+]
+
+
+
+
+
+```
+
+### 带描述文案
+
+```vue
+
+
+
+
+
+```
+
+### 禁用选项
+
+```vue
+
+
+
+
+
+```
+
+### 多列排列
+
+```vue
+
+
+
+
+
+```
+
+### 最少 / 最多选择
+
+```vue
+
+
+
+
+
+```
+
+### 自定义选项内容
+
+```vue
+
+
+
+
+
+
+
+
{{ option.label }}
+
+ {{ option.description }}
+
+
+
+ {{ checked ? '已选中' : '可选择' }}
+
+
+
+
+
+```
+
+## 注意事项
+
+1. **数据驱动**:组选项必须通过 `options` 传入,不再使用多个 `FaCheckbox` 手工拼接。
+2. **v-model 类型**:组件通过 `v-model` 管理选中值数组。
+3. **禁用优先级**:组件整体 `disabled` 为 `true` 时,会覆盖单项可用状态。
+4. **数量限制**:当选中数量小于等于 `min` 时,已选项会被禁用;当选中数量大于等于 `max` 时,未选项会被禁用。
+5. **布局控制**:通过 `class` 和 `optionClass` 自定义多列或卡片式排列,不再提供 `orientation`。
+6. **描述文案布局**:存在 `description` 时,选项会自动切换为顶部对齐布局。
+7. **自定义插槽**:使用 `option` 插槽后,默认复选框本体会隐藏,需要由插槽内容自行承担完整视觉表现。
diff --git a/packages/components/src/checkbox-group/index.vue b/packages/components/src/checkbox-group/index.vue
new file mode 100644
index 00000000..40ba4cd4
--- /dev/null
+++ b/packages/components/src/checkbox-group/index.vue
@@ -0,0 +1,201 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/components/src/checkbox/README.md b/packages/components/src/checkbox/README.md
index e931e84f..bc28a344 100644
--- a/packages/components/src/checkbox/README.md
+++ b/packages/components/src/checkbox/README.md
@@ -1,20 +1,23 @@
# FaCheckbox 复选框
-简洁的复选框组件,支持双向绑定和标签内容插槽。
+单个复选框组件,支持普通选中、禁用和半选状态。
## 使用场景
- 表单中的同意协议选项
-- 多选过滤条件
-- 设置选项开关
-- 列表项批量选择
+- 单个布尔开关配置
+- 树形结构中的半选状态展示
+- 单项功能启用/禁用
## Props
| 属性 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
+| `id` | `string` | 自动生成 | 复选框 id |
| `disabled` | `boolean` | `false` | 是否禁用 |
-| `class` | `HTMLAttributes['class']` | - | 自定义 CSS 类 |
+| `class` | `HTMLAttributes['class']` | - | 外层容器类名 |
+| `itemClass` | `HTMLAttributes['class']` | - | 复选框本体类名 |
+| `labelClass` | `HTMLAttributes['class']` | - | 标签内容类名 |
## Slots
@@ -24,7 +27,11 @@
## Events
-通过 `v-model` 双向绑定,无需单独事件
+| 事件名 | 说明 | 回调参数 |
+|--------|------|----------|
+| `change` | 选中值变化时触发 | `value: boolean \| 'indeterminate' \| undefined` |
+
+通过 `v-model` 实现双向绑定。
## 示例
@@ -36,43 +43,41 @@ const checked = ref(false)
- 同意协议
+
+ 我已阅读并同意服务条款
+
```
-### 基础复选框
+### 半选状态
```vue
- 选项
+
+ 部分选中
+
```
### 禁用状态
-```vue
-
- 禁用选项
- 禁用选中
-
-```
-
-### 复选框组
-
```vue
- 阅读
- 音乐
- 运动
+
+ 禁用未选中
+
+
+ 禁用已选中
+
```
@@ -80,6 +85,10 @@ const hobbies = ref(['reading', 'music'])
### 无标签复选框
```vue
+
+
@@ -87,48 +96,27 @@ const hobbies = ref(['reading', 'music'])
### 自定义样式
-```vue
-
-
- 自定义样式
-
-
-```
-
-### 表单中的使用
-
```vue
-
+
+ 自定义样式
+
```
## 注意事项
-1. **v-model 绑定**:支持单个 boolean 值和数组(多选)两种模式
-2. **标签点击**:点击标签文字也能触发复选框状态切换
-3. **空标签隐藏**:当不提供默认插槽内容时,标签元素会自动隐藏
-4. **禁用状态**:禁用状态下复选框和标签都无法点击
-5. **无障碍支持**:原生支持键盘操作(空格键切换状态)
+1. **单个使用**:`FaCheckbox` 只负责单个复选框,不承担组选项逻辑。
+2. **v-model 类型**:支持 `boolean` 和 `'indeterminate'` 两种状态值。
+3. **标签点击**:点击标签文字也能触发复选框状态切换。
+4. **空标签隐藏**:当不提供默认插槽内容时,标签元素会自动隐藏。
+5. **禁用状态**:禁用状态下复选框和标签都无法点击。
diff --git a/packages/components/src/checkbox/checkbox/Checkbox.vue b/packages/components/src/checkbox/checkbox/Checkbox.vue
old mode 100755
new mode 100644
diff --git a/packages/components/src/checkbox/checkbox/index.ts b/packages/components/src/checkbox/checkbox/index.ts
old mode 100755
new mode 100644
diff --git a/packages/components/src/checkbox/index.vue b/packages/components/src/checkbox/index.vue
old mode 100755
new mode 100644
index 4fcabd1f..1b2b3c33
--- a/packages/components/src/checkbox/index.vue
+++ b/packages/components/src/checkbox/index.vue
@@ -2,6 +2,7 @@
import type { CheckboxRootProps } from 'reka-ui'
import type { HTMLAttributes } from 'vue'
import { cn } from '../../utils'
+import { Label } from '../label/label'
import { Checkbox } from './checkbox'
defineOptions({
@@ -9,20 +10,40 @@ defineOptions({
})
const props = defineProps<{
+ id?: string
disabled?: boolean
class?: HTMLAttributes['class']
+ itemClass?: HTMLAttributes['class']
+ labelClass?: HTMLAttributes['class']
+}>()
+
+const emit = defineEmits<{
+ change: [value: CheckboxRootProps['modelValue'] | undefined]
}>()
const value = defineModel
()
+const generatedId = useId()
+const checkboxId = computed(() => props.id || generatedId)
-const id = useId()
+watch(value, (newValue) => {
+ emit('change', newValue)
+})
-
-