Docs

Documentation versions (currently viewingVaadin 24)

Scroller

Scroller is a component container for creating scrollable areas in the UI.

Scroller is a container component that enables scrollable areas within the UI.

Open in a
new tab
Source code
ScrollerBasic.java
scroller-basic.tsx
scroller-basic.ts

Scroll Direction

Scroller supports four scroll directions: vertical, horizontal, both, and none. The default is both.

Vertical

When vertical scrolling is enabled, users can scroll down if the content exceeds the container’s height. Horizontal overflow, however, is clipped and inaccessible—so the content’s width should be set to 100%.

Horizontal

When horizontal scrolling is enabled, users can scroll sideways if the content exceeds the container’s width. However, vertical overflow is clipped and inaccessible—so the content’s height should be set to 100%.

Note

Use horizontal scrolling with caution, as it’s less common and can be harder for users to notice and interact with—especially on non-mobile devices.

Desktop

Aside from grids, horizontal scrolling is uncommon in desktop or business applications, as it can be unintuitive and cumbersome.

To improve usability, consider using buttons to make horizontal scrolling more noticeable and accessible. For horizontally scrollable lists, it’s good practice to indicate the total number of items and highlight which ones are currently in view.

Mobile

Horizontal scrolling or swiping is more common on mobile, often used for navigation. It can also help conserve vertical space—for example, when displaying less important content such as shortcuts or images.

Open in a
new tab
Source code
ScrollerMobile.java
scroller-mobile.tsx
scroller-mobile.ts

Both

When the scroll direction is set to Both (the default), users can scroll both vertically and horizontally if the content overflows in either direction.

This option is ideal for allowing users to pan across large elements, such as images. It can also serve as a fallback for responsive layouts that may overflow in certain situations.

Open in a
new tab
Source code
ScrollerBoth.java
scroller-both.tsx
scroller-both.ts

None

Use None to hide overflowing content in either direction. No scrollbars are provided, and the clipped content is inaccessible. None is useful in fixed-size or fixed-layout scenarios where overflow would cause issues.

Theme Variants

Scroller has one theme variant: overflow-indicators.

This variant adds borders to indicate when content overflows the scroll container. For example, if more content is available by scrolling down, a bottom border appears. If content overflows at the top, a top border is shown, and so on for other directions.

You shouldn’t add padding to the scroller when using this variant, as it prevents the borders from appearing in the correct positions.

Open in a
new tab
Source code
ScrollerOverflowIndicators.java
scroller-overflow-indicators.tsx
scroller-overflow-indicators.ts
Component Usage recommendations

Horizontal Layout

A layout that aligns components and HTML elements horizontally

Vertical Layout

A layout that aligns components and HTML elements vertically.

6DC07651-5F23-4ADD-B8CD-E87750453184

OSZAR »