Skip to content

feat(Switch): 支持 shape 属性(圆角矩形与线性形态) - #4341

Open
xy200303 wants to merge 3 commits into
Tencent:developfrom
xy200303:feat/switch-shape-variants
Open

feat(Switch): 支持 shape 属性(圆角矩形与线性形态)#4341
xy200303 wants to merge 3 commits into
Tencent:developfrom
xy200303:feat/switch-shape-variants

Conversation

@xy200303

Copy link
Copy Markdown

🤔 这个 PR 的性质是?

  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进

🔗 相关 Issue

💡 需求背景和解决方案

Switch 目前只有单一的胶囊形态。本 PR 为 Switch 补充 shape API 的组件实现,配合 tdesign-common#2640 的公共样式,支持 circle(默认胶囊)、round(圆角矩形)和 line(线性)三种形状。

最终 API(Switch 新增)

属性 类型 默认值 说明
shape circle / round / line circle 开关形状。line 形态不展示开关内容 label

用法:

<Switch shape="round" />
<Switch shape="line" />

实现说明

  • 输出 t-switch--shape-{shape} 类名,与 tdesign-common#2640 的样式选择器对齐
  • line 形态下不渲染 t-switch__content,符合公共样式中 label 由框架 API 层负责不渲染的语义边界
  • 不改变既有结构、状态类名与交互,默认 circle 形态视觉不变

验证

  • 新增 4 个 shape 单测,switch 14 个测试全部通过
  • lint:tsc、eslint、csr/ssr 快照测试通过,已补充 shape demo 快照

📝 更新日志

  • feat(Switch): 支持 shape 属性,新增圆角矩形和线性形态

☑️ 请求合并前的自查清单

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

- add shape prop with circle, round and line options, circle by default
- line shape renders a slim track and does not render switch content label
- related to Tencent/tdesign-common#2563, works with Tencent/tdesign-common#2640
@uyarn

uyarn commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

/update-common 2640

@uyarn uyarn added the 💭 discussion we are discussing label Jul 30, 2026
@tdesign-bot

Copy link
Copy Markdown
Collaborator

TDesign Component Site Preview Open

Component Preview
tdesign-react 完成
@tdesign-react/chat 完成

@pkg-pr-new

pkg-pr-new Bot commented Jul 30, 2026

Copy link
Copy Markdown
  • tdesign-react-demo

    npm i https://pkg.pr.new/Tencent/tdesign-react@4341
    
    npm i https://pkg.pr.new/Tencent/tdesign-react/@tdesign-react/chat@4341
    

commit: 53bf868

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💭 discussion we are discussing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants