Skip to content

Scroller

Wraps a single component in a scrollable container. Useful when the inner content is larger than the available viewport space.

Scroller.builder()
.content(longListComponent)
.style("height: 300px;")
.build()
PropertyTypeDefaultDescription
contentComponentThe component to make scrollable
styleStringInline CSS — typically sets height or width
cssClassesStringCSS class names
var items = new ArrayList<Component>();
for (int i = 0; i < 100; i++) {
items.add(new Text("Item " + i));
}
Scroller.builder()
.content(HorizontalLayout.builder()
.content(items)
.build())
.style("width: 20rem;")
.build()
Scroller.builder()
.content(VerticalLayout.builder()
.content(manyRows)
.build())
.style("height: 400px; overflow-y: auto;")
.build()

Set an explicit height or width on the Scroller via style, otherwise the browser may not know when to show the scrollbar.