scrollbar

fun Modifier.scrollbar(scrollState: ScrollState, scrollbarState: ScrollbarState, direction: Orientation, config: ScrollbarConfig = ScrollbarConfig(), onDraw: DrawScope.(measurements: ScrollbarMeasurements) -> Unit = { measurements -> drawDefaultScrollbar(measurements, config) }): Modifier

This modifier allows you to add a scrollbar to a scrollable composable. The scrollbar's appearance and behavior can be customized using the config parameter.

Recommended to use verticalScrollWithScrollbar or horizontalScrollWithScrollbar for smooth behaviour. Use this modifier if customization is required.

Return

A modifier that adds a scrollbar to the composable.

Parameters

scrollState

The scroll state that the scrollbar will be linked to.

scrollbarState

The state of the scrollbar, including its position and visibility.

direction

The orientation of the scrollbar (horizontal or vertical).

config

The configuration for the scrollbar's appearance and behavior.

onDraw

Optional param to define the custom drawing for Scrollbar.

See also


fun Modifier.scrollbar(scrollState: ScrollState, scrollbarState: ScrollbarState, direction: Orientation, showAlways: Boolean = false, autoHideAnimationSpec: AnimationSpec<Float>? = null, isDragEnabled: Boolean = true, onMeasureAndDraw: ScrollbarMeasureAndDraw): Modifier

This modifier allows you to add a scrollbar to a scrollable composable.

Recommended to use verticalScrollWithScrollbar or horizontalScrollWithScrollbar for smooth behaviour. Use this modifier if customization is required.

Return

A modifier that adds a scrollbar to the composable.

Parameters

scrollState

The scroll state that the scrollbar will be linked to.

scrollbarState

The state of the scrollbar, including its position and visibility.

direction

The orientation of the scrollbar (horizontal or vertical).

showAlways

If true, the scrollbar is always visible. Default is false (auto-hide).

autoHideAnimationSpec

Animation for auto-hiding the scrollbar. Default auto-hide animation if not specified.

isDragEnabled

If true, the scrollbar is draggable. Default is true.

onMeasureAndDraw

To measure and draw the scrollbar. Provides ScrollbarLayoutScope with ScrollbarLayout info to submit measurements and draw the scrollbar.

See also