Skip to content

ScrollView

ScrollView hosts one content View and scrolls vertically by default.

[[huxerui::scope]]
View Document() {
auto scroll = UseScrollController();
return ScrollView {
Column {
ForEach(sections, RenderSection),
}.With(
Padding(24.0F),
Spacing(16.0F)
),
}.Controller(scroll)
.With(ScrollBar());
}

Set .ScrollAxis(Axis::Horizontal) for horizontal content. .Controller(ScrollController) connects imperative coordination without moving the scroll offset into component state.

ScrollController reports ScrollMetrics and supports ScrollTo, ScrollBy, and virtual-layout ScrollToItem. Create a scope-stable controller with UseScrollController(initial_offset).

The runtime owns pointer wheel or touch scrolling, momentum, bounds, clipping, scrollbar interaction, and nested scroll arbitration. Focused text input may request visibility, but user scrolling remains authoritative and can move away from the field.

ScrollView exposes scroll-view role, extent, current offset, and semantic scroll actions.

  • Constructor: explicit ScrollView(View content).
  • Fluent methods: .ScrollAxis(Axis), .Controller(ScrollController).
  • Common modifiers: ScrollBar, Frame, Grow, Background.

Use VirtualList or VirtualGrid for large collections.