Skip to content

feat(Switch): support shape prop#4320

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

feat(Switch): support shape prop#4320
Seeridia wants to merge 3 commits into
Tencent:developfrom
Seeridia:feat/switch-shape

Conversation

@Seeridia

@Seeridia Seeridia commented Jul 2, 2026

Copy link
Copy Markdown

犀牛鸟 Issue,关联 Issue: Tencent/tdesign-common/issues/2563

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

Related issue: Tencent/tdesign-common#2563

💡 需求背景和解决方案

为 Switch 新增 shape 属性,支持 circleroundline 三种形态:

  • circle:默认胶囊形态,保持当前视觉不变。
  • round:圆角矩形形态,样式由 tdesign-common 提供。
  • line:线性形态,样式由 tdesign-common 提供。

最终 API:

shape?: 'circle' | 'round' | 'line';

默认值为 circle


相关 PR:

  1. tdesign-api:feat(Switch): add shape api for web TDesignOteam/tdesign-api#914
  2. tdesign-common:style(Switch): support round and line shapes tdesign-common#2604
  3. tdesign-vue-next:feat(Switch): support shape prop tdesign-vue-next#6776
  4. tdesign-react:feat(Switch): support shape prop #4320
  5. Tdsign-vue:feat(Switch): support shape prop tdesign-vue#3855

设计稿:https://www.figma.com/design/r9jPY6A4EUDvEdoWQ1LVxe/TDesign-for-web--Community----Select?node-id=45757-378235&t=5X597ofKeSefwy0q-1

image

📝 更新日志

  • 本条 PR 不需要纳入 Changelog

tdesign-react

  • feat(Switch): 新增 shape 属性,支持 circleroundline 三种形态

@tdesign-react/chat

  • 本条 PR 不涉及

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

⚠️ 请自检并全部勾选全部选项⚠️

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

Copilot AI review requested due to automatic review settings July 2, 2026 13:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new shape API to the React Switch component to support multiple visual shapes (circle/round/line), updates the rendered DOM/classes accordingly (including hiding label content for line), and wires the change through docs, usage metadata, demos, and tests.

Changes:

  • Add shape prop to Switch typings + defaults, and apply t-switch--shape-* class in rendering.
  • For shape="line", skip rendering switch content/label and avoid evaluating label TNode.
  • Update documentation (CN/EN), usage props metadata, add demo example, and add a unit test for the new behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/components/switch/type.ts Adds shape prop type to Switch API.
packages/components/switch/Switch.tsx Applies shape class and suppresses label/content for line shape.
packages/components/switch/switch.md Documents the new shape prop in CN docs.
packages/components/switch/switch.en-US.md Documents the new shape prop in EN docs.
packages/components/switch/defaultProps.ts Adds default shape: 'circle'.
packages/components/switch/_usage/props.json Exposes shape as an enum in usage metadata.
packages/components/switch/_example/shape.tsx Adds a demo showcasing the three shapes.
packages/components/switch/tests/switch.test.tsx Adds test coverage for shape classes and line label suppression.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/components/switch/type.ts
Comment thread packages/components/switch/defaultProps.ts
Comment thread packages/components/switch/Switch.tsx
@Seeridia

Seeridia commented Jul 2, 2026

Copy link
Copy Markdown
Author

shape: 'circle' 在上游 API 变更 TDesignOteam/tdesign-api#914 中定义,后续组件库 PR 会在 common 样式合入后更新 submodule pointer ,并跑快照(当前 CI 失败是预期的 CSR/SSR snapshot 未更新)等等

@tdesign-bot

tdesign-bot commented Jul 3, 2026

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 3, 2026

Copy link
Copy Markdown
  • tdesign-react-demo

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

commit: 667713d

@RylanBot

RylanBot commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

/update-snapshots

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

⏳ 正在运行快照更新。。。 CI: Open

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants