Scroll Area

A scrolling region with scrollbars that match your theme.

Usage

Code
import { ScrollArea } from '@leverui/components';

export function ScrollAreaUsage() {
  return (
    <ScrollArea.Root>
      <ScrollArea.Viewport>
        <ScrollArea.Content />
      </ScrollArea.Viewport>
      <ScrollArea.Scrollbar>
        <ScrollArea.Thumb />
      </ScrollArea.Scrollbar>
      <ScrollArea.Corner />
    </ScrollArea.Root>
  );
}

The scrollbar sits over the content. Pad ScrollArea.Content on the scrollbar side so the bar never covers text.

Examples

Variants

Use the variant prop to change the scrollbar visibility behavior. Values can be either hover (default) or always.

variant="hover"

variant="always"

Sizes

Use the size prop to change the size of the scroll area. This affects the scrollbar thickness and content padding.

size="xs"

size="sm"

size="md"

size="lg"

Horizontal Scrolling

The scroll area automatically supports horizontal scrolling when content overflows horizontally.

Both Directions

When content overflows in both directions, both scrollbars will appear.

You can render ScrollArea.Corner to show a corner indicator at the intersection of the two scrollbars for a seamless, styled appearance.

Scroll Shadow

Add visual feedback when content is scrollable by implementing scroll shadows that appear at the edges using mask-image. Use the data-overflow-y attribute to only show shadows when content actually overflows—this prevents shadows from appearing when there's a single item or no scrollable content.

Thumb Styling

Customize the appearance of the scrollbar thumb with different styles and colors.

Stick to Bottom

Implement chat-like behavior where new content automatically scrolls to the bottom, but allows manual scrolling. This Solid example uses native scroll events for pinning.

Virtualization

Handle large datasets efficiently by rendering only visible items with TanStack Virtual. Install @tanstack/virtual-core and copy the example's small Solid 2 binding, since TanStack's Solid adapter targets Solid 1.

Store

Use the scroll area with external state management and programmatic control.

Scroll to Side

Programmatically navigate through content by scrolling to different sides and directions.

Scroll to Position

Jump to specific positions or items within the scrollable area with smooth animations.

RTL Support

The scroll area component fully supports Right-to-Left (RTL) languages like Arabic and Hebrew.

With Menu

Combine scroll area with other components like menus to handle overflowing content. This example shows how to create a scrollable menu with many items.

Props

Root

PropDefaultTypeDescription
varianthover'hover' | 'always'When the scrollbar shows.
sizemd'xs' | 'sm' | 'md' | 'lg'Scrollbar thickness and the space around it.
asdivNative HTML tagHTML tag to render.
asChild—Solid render callbackRender your own root element.
unstyledfalseBooleanTurn off the Lever UI styles.
ids—Partial root, viewport, content, scrollbar, thumb IDsIds of the elements the state machine manages.

No colorPalette prop. Set the --leverui-scroll-area-* variables for colors and scrollbar thickness. ScrollArea.PropsProvider sets the default look for the scroll areas inside it. Defaults are reactive. A prop on a root wins.

Viewport

PropDefaultTypeDescription
asdivNative HTML tagHTML tag to render.
asChild—Solid render callbackRender your own element.

For scroll shadows, give Viewport a class and style its data-overflow-y state.

Content

PropDefaultTypeDescription
asdivNative HTML tagHTML tag to render.
asChild—Solid render callbackRender your own element.

Scrollbar

PropDefaultTypeDescription
asdivNative HTML tagHTML tag to render.
asChild—Solid render callbackRender your own element.
orientationverticalScroll orientationDirection this scrollbar scrolls.

Scrollbar adds a Thumb when it has no children. For overflow in both directions, render a horizontal scrollbar and a vertical one.

Thumb

PropDefaultTypeDescription
asdivNative HTML tagHTML tag to render.
asChild—Solid render callbackRender your own element.

Give it a class or set --leverui-scroll-area-thumb-color.

Corner

PropDefaultTypeDescription
asdivNative HTML tagHTML tag to render.
asChild—Solid render callbackRender your own element.

Fills the square where the two scrollbars meet.

Explorer

Click a part name in the sidebar to highlight it in the preview.

Loading explorer…

Component Anatomy

Hover to highlight, click to select parts