feat(Switch): support shape prop#4320
Open
Seeridia wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
shapeprop to Switch typings + defaults, and applyt-switch--shape-*class in rendering. - For
shape="line", skip rendering switch content/label and avoid evaluatinglabelTNode. - 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.
This was referenced Jul 2, 2026
Author
|
|
Collaborator
TDesign Component Site Preview Open
|
commit: |
Collaborator
|
/update-snapshots |
Contributor
|
⏳ 正在运行快照更新。。。 CI: Open |
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
Related issue: Tencent/tdesign-common#2563
💡 需求背景和解决方案
为 Switch 新增
shape属性,支持circle、round、line三种形态:circle:默认胶囊形态,保持当前视觉不变。round:圆角矩形形态,样式由tdesign-common提供。line:线性形态,样式由tdesign-common提供。最终 API:
默认值为
circle。相关 PR:
设计稿:https://www.figma.com/design/r9jPY6A4EUDvEdoWQ1LVxe/TDesign-for-web--Community----Select?node-id=45757-378235&t=5X597ofKeSefwy0q-1
📝 更新日志
tdesign-react
shape属性,支持circle、round、line三种形态@tdesign-react/chat
☑️ 请求合并前的自查清单