Using px unit for height and width in certain parts breaks the UI when root font size is not 16px. This means that if the user changes the font size in the browser settings or the root font size is set to a value other than 16px, the styling breaks.
I haven't checked all the components, but I found this behavior on Switch component. It was using fixed px units for width and height. In contrast, the original shadcn/ui, it uses rem units only.
Here are the classes for the Switch in shadcn-svelte:
Describe the bug
Using px unit for height and width in certain parts breaks the UI when root font size is not 16px. This means that if the user changes the font size in the browser settings or the root font size is set to a value other than 16px, the styling breaks.
I haven't checked all the components, but I found this behavior on
Switch
component. It was using fixed px units for width and height. In contrast, the original shadcn/ui, it uses rem units only.Switch
in shadcn-svelte:Switch
in the original shadcn/ui:The only part difference is
h-[24px] w-[44px]
andh-6 w-11
.Here are examples of the issue when the root font size is changed:
Note: The select also breaks because it has a fixed width of 145px.
Could you please explain the reason behind using
px
instead ofrem
because it seems intentional. If possible, please consider usingrem
units.Thank you!
Reproduction
Change the root font size.
Logs
No response
System Info
Severity
annoyance