ui icon indicating copy to clipboard operation
ui copied to clipboard

[bug]: SidebarMenuButton size='lg' doesn't collapse properly to icon-only mode

Open rabin-thami opened this issue 2 weeks ago • 3 comments

Describe the bug

Bug: SidebarMenuButton size="lg" doesn't collapse properly to icon-only mode

Description

When using <SidebarMenuButton size="lg">, the button doesn't properly collapse to icon-only mode when the sidebar is in collapsible="icon" state. The text remains visible instead of being hidden like it does with size="default".

Steps to Reproduce

  1. Create a sidebar with collapsible="icon" mode
  2. Add a <SidebarMenuButton tooltip="Title" size="lg"> containing an icon and text
  3. Collapse the sidebar to icon-only mode
  4. Observe that the text is still visible

Expected Behavior

The button should shrink to 32x32px (icon-only) when collapsed, matching the behavior of size="default".

Actual Behavior

The button retains its full height (48px) and text remains visible when collapsed.

Root Cause

In sidebarMenuButtonVariants, the base class includes group-data-[collapsible=icon]:size-8! which constrains the button size when collapsed. However, the lg variant only has:

lg: 'h-12 text-sm group-data-[collapsible=icon]:p-0!',

Image

Affected component/components

Sidebar

How to reproduce

  1. Use the @shadcn/ui sidebar with collapsible="icon" enabled.
  2. Add a <SidebarMenuButton size="lg"> containing an icon and text.
  3. Collapse the sidebar to icon-only mode.
  4. Notice that the text is still visible and the button stays h-12 instead of collapsing to size-8.

### System Info

```bash
**System Info**

- Operating System: Windows 10
- Browser: Chrome 143 (latest)
- Node.js: v20+
- Next.js: v15 (App Router)
- @shadcn/ui: latest version
- Tailwind CSS: v4
- Using: `<SidebarMenuButton size="lg">`
- Sidebar: `collapsible="icon"`

Before submitting

  • [x] I've made research efforts and searched the documentation
  • [x] I've searched for existing issues

rabin-thami avatar Dec 07 '25 16:12 rabin-thami

hey, try to remove this group-data-[collapsible=icon]:p-0!

from sidebar.tsx

- lg: "h-12 text-sm group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-0!",
+ lg: "h-12 text-sm group-data-[collapsible=icon]:size-8!",

it's padding problem, i've tested it without adding group-data-[collapsible=icon]:size-8! and it worked.

Hamed-Ajaj avatar Dec 08 '25 11:12 Hamed-Ajaj

can i fix this issue ???

RAGHUKHAJURIA avatar Dec 09 '25 16:12 RAGHUKHAJURIA

https://github.com/shadcn-ui/ui/pull/8984

Hamed-Ajaj avatar Dec 09 '25 20:12 Hamed-Ajaj