shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
74.76k stars 4.65k forks source link

how to i use ScrollArea in nextjs 14 root layou. #2706

Closed ruru-m07 closed 9 months ago

ruru-m07 commented 9 months ago

hey i try to use ScrollArea in my body but it dose'n work

import "./globals.css";
import { ThemeProvider } from "@/components/theme-provider";
import { ScrollArea } from "@/components/ui/scroll-area";

export default async function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  // const isAuthenticated = cookies().get("authjs.session-token");
  return (
      <html lang="en">
        <body>
          <ThemeProvider
            attribute="class"
            defaultTheme="system"
            enableSystem
            disableTransitionOnChange
          >
              <ScrollArea>{children}</ScrollArea>
          </ThemeProvider>
        </body>
      </html>
  );
}

image

need help. pls 🔥

dan5py commented 9 months ago

Hi @ruru-m07, you can set the scrollarea's child height:

import "./globals.css";
import { ThemeProvider } from "@/components/theme-provider";
import { ScrollArea } from "@/components/ui/scroll-area";

export default async function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en">
      <body>
        <ThemeProvider
          attribute="class"
          defaultTheme="system"
          enableSystem
          disableTransitionOnChange
        >
          <ScrollArea>
            <div className="h-screen">{children}</div>
          </ScrollArea>
        </ThemeProvider>
      </body>
    </html>
  );
}
ruru-m07 commented 9 months ago

yes! that's work for me tnks