feat(switch): 支持 circle/round/line 三种 shape - #4342
Open
shide-chuanzhang wants to merge 2 commits into
Open
Conversation
shide-chuanzhang
requested review from
HaixingOoO,
NWYLZW,
RylanBot,
ZWkang,
carolin913,
honkinglin and
uyarn
as code owners
July 30, 2026 04:30
shide-chuanzhang
force-pushed
the
feat/switch-shape
branch
from
July 30, 2026 05:05
252648d to
643e08d
Compare
type.ts 和 defaultProps.ts 加了 shape 属性,默认 circle。 Switch.tsx 的改动: - contentNode 在 line 形态返回 null,不渲染 content DOM - 加了 derivedAriaLabel,line 形态从 label 推导 aria-label - className 加了 shape 修饰 - 补了 aria-checked 和 aria-disabled - content div 在 line 形态不渲染 样式在 tdesign-common 仓库提,对应 PR Tencent#2651。 issue Tencent#2563
rerender 不会重置 state,click 后 innerChecked 仍为 true, 用独立 render 测试默认值 '已关闭'
shide-chuanzhang
force-pushed
the
feat/switch-shape
branch
from
July 30, 2026 05:08
643e08d to
59a7678
Compare
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.
对应 issue tdesign-common#2563,给 Switch 加了 shape 属性,支持 circle(默认)、round、line 三种。
组件侧的改动:
type.ts 加了 shape?: 'circle' | 'round' | 'line',defaultProps 默认值 circle。
Switch.tsx 做了这些:
测试覆盖了 shape 切换、line 不渲染 content、aria-label 推导、aria-disabled、aria-checked。
样式部分在 tdesign-common 仓库,对应 PR tdesign-common#2651。