Scroll Area

A scroller whose thin bars appear while it is hovered or moving, with an optional fade on the edges there is more past.

01Preview

01
Full screen

02Installation

npx shadcn@latest add https://aiellie.app/r/scroll-area.json

03API reference

06
From the Base UI documentation

Groups all parts of the scroll area. Renders a <div> element.

Props

PropTypeDefaultDescription
overflowEdgeThresholdnumber | Partial<{ xStart: number; xEnd: number; yStart: number; yEnd: number }>0The threshold in pixels that must be passed before the overflow edge attributes are applied. Accepts a single number for all edges or an object to configure them individually.
classNamestring | ((state: ScrollArea.Root.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component's state.
styleReact.CSSProperties | ((state: ScrollArea.Root.State) => React.CSSProperties | undefined)-Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement | ((props: HTMLProps, state: ScrollArea.Root.State) => ReactElement)-Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.

Data Attributes

AttributeTypeDescription
data-has-overflow-x-Present when the scroll area content is wider than the viewport.
data-has-overflow-y-Present when the scroll area content is taller than the viewport.
data-overflow-x-end-Present when there is overflow on the horizontal end side.
data-overflow-x-start-Present when there is overflow on the horizontal start side.
data-overflow-y-end-Present when there is overflow on the vertical end side.
data-overflow-y-start-Present when there is overflow on the vertical start side.
data-scrolling-Present when the user scrolls inside the scroll area.

CSS Variables

VariableTypeDescription
--scroll-area-corner-heightnumberThe scroll area's corner height.
--scroll-area-corner-widthnumberThe scroll area's corner width.