File tree Expand file tree Collapse file tree
packages/web/src/components/ui/switch Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828 display : block;
2929 width : 100% ;
3030 height : 100% ;
31+ box-sizing : border-box;
3132 border-radius : var (--radius-full );
3233 background : var (--bg-hover );
3334 border : 1px solid var (--border );
5556
5657.thumb {
5758 position : absolute;
58- top : var ( --switch-thumb-offset ) ;
59+ top : 50 % ;
5960 left : var (--switch-thumb-offset );
6061 width : var (--switch-thumb-size );
6162 height : var (--switch-thumb-size );
63+ box-sizing : border-box;
6264 border-radius : 50% ;
6365 background : var (--text-primary );
6466 box-shadow : var (--shadow-sm );
67+ transform : translate3d (0 , -50% , 0 );
6568 transition :
6669 transform var (--duration-fast ) var (--ease-out ),
6770 background var (--duration-fast ) var (--ease-out );
6871}
6972
7073.checked .thumb {
71- transform : translateX (var (--switch-thumb-translate-x ));
74+ left : calc (100% - var (--switch-thumb-size ) - var (--switch-thumb-offset ));
75+ transform : translate3d (0 , -50% , 0 );
7276}
7377
7478.switch : disabled .track ,
Original file line number Diff line number Diff line change @@ -22,22 +22,19 @@ const sizeMap: Record<
2222 readonly trackHeight : string ;
2323 readonly thumbSize : string ;
2424 readonly offset : string ;
25- readonly translateX : string ;
2625 }
2726> = {
2827 sm : {
2928 trackWidth : "32px" ,
3029 trackHeight : "18px" ,
3130 thumbSize : "14px" ,
3231 offset : "2px" ,
33- translateX : "14px" ,
3432 } ,
3533 md : {
3634 trackWidth : "36px" ,
3735 trackHeight : "20px" ,
3836 thumbSize : "16px" ,
3937 offset : "2px" ,
40- translateX : "16px" ,
4138 } ,
4239} ;
4340
@@ -73,7 +70,6 @@ export function Switch({
7370 "--switch-track-height" : dimensions . trackHeight ,
7471 "--switch-thumb-size" : dimensions . thumbSize ,
7572 "--switch-thumb-offset" : dimensions . offset ,
76- "--switch-thumb-translate-x" : dimensions . translateX ,
7773 ...style ,
7874 } as CSSProperties
7975 }
You can’t perform that action at this time.
0 commit comments