ui: [bug]: Scroll issue on new block sidebar-16

Describe the bug

Hi @Jacksonmills @shadcn Thanks for the blocks, but I have some issue here

  1. the width when resizing is weird, for some md or other screensize, the content show some weird horizontal scroll
  2. when content is just short, the block still give me vertical scroll, the remaining I think equal to header height

Here my trial & error

  1. On first point happen on sidebar-7 to, What do you thing or any best practice, I dont know this is the best practice or not, but I fix using (thanks @rezaafaisal ) :
<div className="[--header-height:calc(theme(spacing.14))]">
  <SidebarProvider className="flex flex-col">
    <SiteHeader />
    <div className="flex flex-1">
      <AppSidebar />
      <SidebarInset
        className={cn(
          'w-full',

          'peer-data-[state=collapsed]:max-w-[calc(100vw-var(--sidebar-width-icon)-1rem)]',
          'peer-data-[state=expanded]:max-w-[calc(100vw-var(--sidebar-width)-1rem)]',

          'transition-[width] duration-200 ease-linear'
        )}
      >
        {children}
      </SidebarInset>
    </div>
  </SidebarProvider>
</div>;
  1. I dont know how to solve, but the scroll still annonying

image

https://github.com/user-attachments/assets/1ac74947-359d-4ff8-a01e-32a09a530ad6

here the v0 if you want demo https://v0.dev/chat/sidebar-16-TO3dinOZ5o3?b=b_IiiEJQ2DaPR https://kzmjklowe3cyql650pxu.lite.vusercontent.net/dashboard

Affected component/components

sidebar

How to reproduce

image

https://github.com/user-attachments/assets/1ac74947-359d-4ff8-a01e-32a09a530ad6

here the v0 if you want demo https://v0.dev/chat/sidebar-16-TO3dinOZ5o3?b=b_IiiEJQ2DaPR https://kzmjklowe3cyql650pxu.lite.vusercontent.net/dashboard

Codesandbox/StackBlitz link

No response

Logs


System Info

WSL

Before submitting

  • I’ve made research efforts and searched the documentation
  • I’ve searched for existing issues

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 18 (5 by maintainers)

Commits related to this issue

Most upvoted comments

got rid of vertical scroll by deleting h-svh from Sidebar className and min-h-svh from SidebarInset delete peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] also if you are using variant="inset"

diff --git a/components/ui/sidebar.tsx b/components/ui/sidebar.tsx
index 5134c0f..1ce546b 100644
--- a/components/ui/sidebar.tsx
+++ b/components/ui/sidebar.tsx
@@ -224,7 +224,7 @@ const Sidebar = React.forwardRef<
         {/* This is what handles the sidebar gap on desktop */}
         <div
           className={cn(
-            "relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear",
+            "relative w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear",
             "group-data-[collapsible=offcanvas]:w-0",
             "group-data-[side=right]:rotate-180",
             variant === "floating" || variant === "inset"
@@ -322,8 +322,8 @@ const SidebarInset = React.forwardRef<
     <main
       ref={ref}
       className={cn(
-        "relative flex min-h-svh flex-1 flex-col bg-background",
-        "peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",
+        "relative flex flex-1 flex-col bg-background",
+        "md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",
         className
       )}
       {...props}

I’m assuming you’re on tailwind v4 which has some changes to get it to work.

Cool well, this was something i’ve solved already, but you’re on your own.

I’m assuming you’re on tailwind v4 which has some changes to get it to work.

I’m so sorry, I don’t get the point in your comment @rubixvi , it is very inappropriate you not help or give solution but just comment to ASSUME that when you can first check & re-check the code that I share, you can download my demo code in v0 and check for yourself what version I am using

Here my package.json generated from v0 download, I’m using tailwindcss v3

{
  "name": "my-v0-project",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    ...
  },
  "devDependencies": {
    "@types/node": "^22",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "postcss": "^8",
    "tailwindcss": "^3.4.17",
    "typescript": "^5"
  }
}

Hi @shadcn @Jacksonmills I try out your updated code on my local and I can confirm on my scenario this issue has been fixed, thank you for your support, I think this issue can be closed 😃

Thank you so much

@adiramardiani not sure if you saw but there was an update to the v4 example that fixes the horizontal scroll: #6802 (comment) (test here: https://v4-git-shadcn-fix-v4-demo-responsive-shadcn-pro.vercel.app/)

It’s merged and can also be seen at https://v4.shadcn.com

@adiramardiani not sure if you saw but there was an update to the v4 example that fixes the horizontal scroll: https://github.com/shadcn-ui/ui/pull/6802#issuecomment-2690092974 (test here: https://v4-git-shadcn-fix-v4-demo-responsive-shadcn-pro.vercel.app/)

thanks @Jacksonmills I won’t be able to open PR for a while so you can take care of it

Just tested it myself… good catch @Graphity! Do you want to open a PR for the fix? I can take care of it too, since I needed to add Label to the dep components anyway.

Let me work on this