feat(Checkbox): 支持按钮风格多选按钮组#4337
Open
Grant-ccc wants to merge 3 commits into
Open
Conversation
added 2 commits
July 25, 2026 17:25
- 支持 Checkbox.Button 按钮风格 - 新增 8 个单元测试用例 - 修复 Check.tsx 嵌套三元表达式 Closes Tencent#2562
- 新增 Checkbox.Button 子组件 - 支持 theme/variant/direction 属性 - 更新 TypeScript 类型定义 - 新增按钮风格 Demo 示例 - 更新文档说明 Related: Tencent#2562
Grant-ccc
requested review from
HaixingOoO,
NWYLZW,
RylanBot,
ZWkang,
carolin913,
honkinglin and
uyarn
as code owners
July 25, 2026 10:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 这个 PR 的性质是?
🔗 相关 Issue
closes #2562
💡 需求背景和解决方案
问题背景:
Issue #2562 要求 Checkbox 多选框组支持按钮风格。当前 Checkbox 仅支持传统复选框样式,缺少类似 Radio.Button 的按钮风格支持,无法满足部分业务场景的需求。
解决方案:
参考 Radio.Button 的实现方式,为 Checkbox.Group 新增按钮风格支持。
最终 API 实现:
用法示例:
UI/交互改进:
修复前:边框型按钮存在间隙和错位,选中态边框断裂
修复后:
Design Token 对齐(Figma 规范):
📝 更新日志
tdesign-react
theme="button"开启按钮风格variant属性:outline(边框型)、default-filled(填充型-白色)、primary-filled(填充型-蓝色)direction="vertical"纵向排列Checkbox.Button子组件@tdesign-react/chat
☑️ 请求合并前的自查清单
🧪 技术实现细节
CSS 变量(
_var.less):新增 25+ 按钮风格专用变量:
样式实现技巧:
边框型无缝拼接:
纵向排列:
✅ 测试覆盖
新增 8 个单元测试用例:
📦 文件变更
核心实现:
packages/components/checkbox/Checkbox.tsx- 新增 Checkbox.Button 导出packages/components/checkbox/CheckboxGroup.tsx- 支持 theme/variant/directionpackages/components/checkbox/type.ts- 新增类型定义packages/components/checkbox/defaultProps.ts- 新增默认值样式文件:
packages/common/style/web/components/checkbox/_var.less- 新增按钮风格变量packages/common/style/web/components/checkbox/_checkbox-button.less- 重构样式测试文件:
packages/components/checkbox/__tests__/checkbox.test.tsx- 新增 8 个测试用例文档与 Demo:
packages/components/checkbox/_example/button.tsx- 新增按钮风格 Demopackages/components/checkbox/checkbox.md- 更新文档🎯 Breaking Changes
无破坏性变更,完全向后兼容