Scroll Area
basecn/scroll-areaFreeComponent
Augments native scroll functionality for custom, cross-browser styling.
Live preview
live · rendered by the registry
Rendered by basecn on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://basecn.dev/r/scroll-area.jsonSource
1import * as React from "react";2import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area";34import { cn } from "@/lib/utils";56function ScrollArea({7 className,8 children,9 ...props10}: ScrollAreaPrimitive.Root.Props) {11 return (12 <ScrollAreaPrimitive.Root13 data-slot="scroll-area"14 className={cn("relative", className)}15 {...props}16 >17 <ScrollAreaPrimitive.Viewport18 data-slot="scroll-area-viewport"19 className="focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1"20 >21 <ScrollAreaPrimitive.Content>{children}</ScrollAreaPrimitive.Content>22 </ScrollAreaPrimitive.Viewport>23 <ScrollBar />24 <ScrollAreaPrimitive.Corner />25 </ScrollAreaPrimitive.Root>26 );27}2829function ScrollBar({30 className,31 orientation = "vertical",32 ...props33}: ScrollAreaPrimitive.Scrollbar.Props) {34 return (35 <ScrollAreaPrimitive.Scrollbar36 data-slot="scroll-area-scrollbar"37 orientation={orientation}38 className={cn(39 "flex touch-none p-px transition-[colors,opacity] select-none opacity-0 data-[hovering]:opacity-100 data-[scrolling]:opacity-100 duration-150 delay-300 data-[hovering]:duration-75 data-[scrolling]:duration-75 data-[hovering]:delay-0 data-[scrolling]:delay-0",40 orientation === "vertical" &&41 "h-full w-2.5 border-l border-l-transparent",42 orientation === "horizontal" &&43 "h-2.5 flex-col border-t border-t-transparent",44 className45 )}46 {...props}47 >48 <ScrollAreaPrimitive.Thumb49 data-slot="scroll-area-thumb"50 className="bg-border relative flex-1 rounded-full"51 />52 </ScrollAreaPrimitive.Scrollbar>53 );54}5556export { ScrollArea, ScrollBar };
What it pulls in
npm packages
Files it writes
More from basecn
All 56 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | basecn | Components | Free | 2 deps | |
| Alertalert | basecn | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | basecn | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | basecn | Components | Free | no deps | |
| Autocompleteautocomplete | basecn | Components | Free | 2 deps | |
| Avataravatar | basecn | Components | Free | 1 dep | |
| Badgebadge | basecn | Components | Free | 2 deps | |
| Breadcrumbbreadcrumb | basecn | Components | Free | 2 deps |
