huntabyte / shadcn-svelte

shadcn/ui, but for Svelte. ✨
https://shadcn-svelte.com
MIT License
4.48k stars 283 forks source link

Fixed px units in Switch Component cause UI scaling issue #1146

Open zeroberry opened 1 month ago

zeroberry commented 1 month ago

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.

The only part difference is h-[24px] w-[44px] and h-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 of rem because it seems intentional. If possible, please consider using rem units.

Thank you!

Reproduction

Change the root font size.

<html style="font-size: 10px;">

Logs

No response

System Info

Not necessary

Severity

annoyance

Michael-Obele commented 1 week ago

Hi, I'd love to help with this; should I go ahead?