Skip to main content

strata_ui/
scroll_area.rs

1//! Declarative `<ScrollArea>` Component with Smooth Kinetic Physics.
2
3#![allow(non_snake_case)]
4
5use strata_dom::{NodeBlueprint, View};
6use strata_macro::{component, rsx};
7
8/// Declarative scroll container primitive with smooth kinetic momentum physics,
9/// floating non-layout-shifting scrollbars with hover expansion and drag handles,
10/// and scroll position preservation across component re-renders.
11#[component]
12pub fn ScrollArea(
13    id: Option<&'static str>,
14    class: Option<&'static str>,
15    children: Option<Vec<NodeBlueprint>>,
16    show_scrollbar: Option<bool>,
17) -> View {
18    let custom = class.unwrap_or("");
19    let container_id = id.unwrap_or("");
20    let _with_bar = show_scrollbar.unwrap_or(true);
21
22    rsx! {
23        <div
24            id={container_id}
25            class={format!("relative overflow-y-auto flex-1 flex flex-col min-h-0 w-full {}", custom)}
26        >
27            {children.unwrap_or_default()}
28        </div>
29    }
30}