Function freya::components::ScrollView

pub fn ScrollView(_: ScrollViewProps) -> Option<VNode>
Expand description

Scrollable area with bidirectional support and scrollbars.

§Example

fn app() -> Element {
    rsx!(
        ScrollView {
            rect {
                background: "blue",
                height: "400",
                width: "100%"
            }
            rect {
                background: "red",
                height: "400",
                width: "100%"
             }
        }
    )
}

§With a Scroll Controller

fn app() -> Element {
    let mut scroll_controller = use_scroll_controller(|| ScrollConfig::default());

    rsx!(
        ScrollView {
            scroll_controller,
            rect {
                background: "blue",
                height: "400",
                width: "100%"
            }
            Button {
                label {
                    onclick: move |_| {
                         scroll_controller.scroll_to(ScrollPosition::Start, ScrollDirection::Vertical);
                    },
                    label {
                        "Scroll up"
                    }
                }
            }
            rect {
                background: "red",
                height: "400",
                width: "100%"
            }
        }
    )
}