Skip to content

ScrollableState

@Stable



class ScrollableState

Mutable state holder for a Scrollable composable.

Create and remember an instance via rememberScrollableState and pass it to Scrollable when you need programmatic control over the scroll position.

Constructors

ScrollableState

constructor()

Properties

childSize

var childSize: Int

Size of the scrollable content in the scroll axis, in pixels.

containerSize

Size of the visible container in the scroll axis, in pixels.

currentScrollPosition

Smoothly interpolated scroll position used for actual rendering.

isDraggingScrollbar

Whether the user is currently dragging the scrollbar thumb.

lastInteractTime

Timestamp of the last user interaction (used for fade-out animation).

maxScroll

var maxScroll: Int

Maximum scroll offset (content size − container size).

scrollOffset

Current target scroll offset in pixels. Animate towards currentScrollPosition.

Functions

onInteraction

Records an interaction so the scrollbar fade-out timer resets.

scrollBy

fun scrollBy(delta: Double)

Scrolls by delta pixels, clamping the result to the valid range.

Parameters

  • delta: Positive values scroll forward (down/right); negative scrolls back.