ZBMui

Scroll Area

View markdown

A native scroll container with custom scrollbars.

Installation

Copy and paste the following code into your project.

components/ui/scroll-area.tsx

Usage

Examples

Horizontal scroll

Both horizontal and vertical scroll

Scroll with fade effect

Pass scrollFade prop to ScrollArea to add fade effect at the edges.

Scrollbar gutter

Enable scrollbarGutter prop to add space for the scrollbar to avoid layout shift.

Scrollbar custom size and margin

Customize the scrollbar size using CSS variable --scrollbar-size. Default size is 6px.

You can also customize the scrollbar margin using CSS variable --scrollbar-margin. Default margin is 4px.

Scroll area with max-height

If you want to use max-height instead of height for the ScrollArea component, you have to follow one of the following approaches:

  1. Set display: flex and flex-direction: column to the ScrollArea component. This will make the ScrollArea component take the full height of its parent container and allow it to scroll when the content exceeds the max-height.
  1. Wrap the ScrollArea component inside a parent container and set the display: grid to the parent container. This will make the ScrollArea component take the full height of its parent container and allow it to scroll when the content exceeds the max-height.

API Reference

Scroll Area props

Component type props
Prop
Type
Default
Expand prop details

Scroll Area CSS variables

Component type props
Prop
Type
Default
Expand prop details

ZBMui

Built by the ZBM.

© 2026 ZBM ui. All rights reserved.