Skip to content

Scroll Area

A custom scrollable viewport container for overflow content.

When to use

  • Constraining long content to a fixed-height region.
  • Building scrollable lists and panels.

API

ScrollArea::new(id)

Creates a scroll area with the given element ID.

MethodTypeDefaultDescription
.h(height)impl Into<DefiniteLength>Fixed height for the scroll container
.w(width)impl Into<DefiniteLength>Fixed width for the scroll container
.child(child)impl IntoElementAdd scrollable content

Usage

rust
use gpui::{Component, div, prelude::*};
use components::ScrollArea;

div().child(Component::new(
    ScrollArea::new("my-scroll-area")
        .h(px(200.0))
        .child(long_content),
))

Copy the source

crates/components/src/scroll_area.rs — self-contained, stateless, and free to modify.

Released under the MIT License.