feat(Switch): support shape prop#6776
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new shape prop to the Switch component to support circle (default), round, and line variants, aligning the Vue Next implementation with the desired API and common styles. The update also adjusts rendering behavior so line does not render (or evaluate) the label content, and updates docs/demos/tests accordingly.
Changes:
- Introduce
shape?: 'circle' | 'round' | 'line'with defaultcircle, including runtime prop config and usage metadata. - Apply a shape BEM class (
t-switch--shape-*) and skip rendering switch content forshape="line". - Add demo + tests + snapshot updates covering default and
linebehavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/components/switch/type.ts | Adds shape to the public TS props interface. |
| packages/components/switch/switch.tsx | Adds shape class and adjusts render logic to omit content for line. |
| packages/components/switch/switch.md | Documents shape in CN API table. |
| packages/components/switch/switch.en-US.md | Documents shape in EN API table. |
| packages/components/switch/props.ts | Adds runtime Vue prop definition for shape (default + validator). |
| packages/components/switch/_usage/props.json | Exposes shape in usage metadata as an enum. |
| packages/components/switch/_example/shape.vue | Adds a demo showcasing the three shapes. |
| packages/components/switch/tests/base.test.tsx | Adds unit tests for shape default/round/line rendering behavior. |
| packages/components/switch/tests/snapshots/switch.test.tsx.snap | Updates snapshots to include the new default shape class. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
TDesign Component Site Preview Open
|
commit: |
确实是,对于这个组件而言,考虑 滑块的动画(Thumb 如果用 |



🤔 这个 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-vue-next
shape属性,支持circle、round、line三种形态@tdesign-vue-next/chat
@tdesign-vue-next/nuxt
@tdesign-vue-next/auto-import-resolver
☑️ 请求合并前的自查清单