Scrolling

Loading Ebi…
fn Row(label: String, color: String): Element {
    return <Box shrink-0 p-12 rounded-lg fill={Color(color)}>
        <Text text-lg>{label}</Text>
    </Box>
}

let viewport = <Box w-54% h-52% flex-col p-10 gap-8 rounded-xl bg-card_bg_dark
    overflow-y-auto x_align={Align.Center} y_align={Align.Center}>
    {Row("01 · Start", "blue4")}
    {Row("02 · Keep going", "purple4")}
    {Row("03 · Almost there", "green5")}
    {Row("04 · End", "orange5")}
</Box>
viewport
wait(400ms)
viewport.scroll_to(y=100%, duration=1.3s, ease="smootherstep")
wait(400ms)
viewport.scroll_to(y=0%, duration=1.3s, ease="smootherstep")

Resize the viewport to resize every row. Each row keeps the height of its text and padding. Try scrolling to y=50% to reach the middle of the overflow.

Scroll API

view.scroll_to(
    to?: List<Length, 2> | List<Percent, 2>,
    x?: Length | Percent, y?: Length | Percent,
    line?: Number, range?: CodeRange,
    align: "nearest" | "start" | "center" | "end" = "nearest",
    duration: Duration = 300ms, ease: Easing = "spring"
): Animation

Use to for both axes, x or y for a single axis, or line or range with Code. Line numbers start at 1.

Use overflow for both axes or overflow_x and overflow_y to control scrolling separately. Set an axis to "auto" for a scrollbar when needed, "scroll" for a permanent scrollbar, or "hidden" to scroll with code alone. The viewport clips its children to its shape, even when only one axis scrolls. Set both axes to "visible" to let children extend beyond the box.

Shared reactive offset

Set scroll={offset} on multiple views to keep them together. Animate offset with animate(...) to move the group.