You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug]: use-mobile.ts uses pixel logic, causing UI state de-sync with Tailwind CSS rem breakpoints #12393
In Tailwind v4, the md: modifier is evaluated dynamically as a relative size (48rem).
If a user scales their default browser font size up to 24px, Tailwind's md: media query dynamically targets 1152px (48rem × 24px). If the browser window is at 1000px, Tailwind hides the desktop layout container completely via hidden md:block.
However, because use-mobile.ts is hardcoded to 768px, the React logic evaluates isMobile as false. The component completely skips rendering the mobile <Sheet>, and attempts to render the desktop container which Tailwind has hidden. The sidebar completely disappears from the layout, and the SidebarTrigger button stops functioning entirely between 768px and 1152px because it is stuck trying to toggle a hidden desktop layout instead of opening the mobile drawer.
works fine if browser font size is using recommended size.
Affected component/components
sidebar, use-mobile
How to reproduce
Use a standard layout utilizing the shadcn Sidebar component (which implements use-mobile.ts).
Open browser settings and change the Default Font Size from Medium (16px) to Very Large (24px).
Sidebar correctly goes into mobile mode at 1152px meanwhile cant open it using SidebarTrigger until it hits below 768px
Hi, I’d like to take this. I can reproduce it with the browser font size set to 24px. Changing the media query to rem isn’t enough on its own, because onChange and the initial state still compare window.innerWidth to the pixel breakpoint. My plan is to use a (width < 48rem) query and read mql.matches, keeping the mobileBreakpoint param in px so existing callers aren’t affected. Happy to open a PR if that approach works for you.
Besides switching the media query to rem, it also reads mql.matches instead of window.innerWidth, since the state was derived from innerWidth before. Happy to adjust if you'd prefer a different approach.
Activity
shaurya-10000 commentedon Oct 20, 2026
Hi, I’d like to take this. I can reproduce it with the browser font size set to 24px. Changing the media query to rem isn’t enough on its own, because onChange and the initial state still compare window.innerWidth to the pixel breakpoint. My plan is to use a (width < 48rem) query and read mql.matches, keeping the mobileBreakpoint param in px so existing callers aren’t affected. Happy to open a PR if that approach works for you.
shaurya-10000 commentedon Oct 20, 2026
I've opened a PR for this: #12397
Besides switching the media query to rem, it also reads
mql.matchesinstead ofwindow.innerWidth, since the state was derived frominnerWidthbefore. Happy to adjust if you'd prefer a different approach.fix(use-mobile): sync breakpoint with rem-based Tailwind breakpoints