androidx.compose.material3

scrollbarSince 1.12

Function

No hand-written docs yet.

A scrollbar that represents the current scroll position of a scrolling component.

Parameters

@Composable
fun Modifier.scrollbar(
    state: ScrollIndicatorState?,
    orientation: Orientation,
    thumbColor: Color = ScrollbarDefaults.thumbColor,
    trackColor: Color = Color.Transparent,
    thickness: Dp = ScrollbarDefaults.Thickness,
    thumbMinLength: Dp = ScrollbarDefaults.ThumbMinLength,
    thumbMaxLengthFraction: Float = ScrollbarDefaults.ThumbMaxLengthFraction,
    isFadeEnabled: Boolean = true,
    fadeDurationMillis: Int = ScrollbarDefaults.ThumbFadeDurationMillis,
    fadeDelayMillis: Int = ScrollbarDefaults.ThumbFadeDelayMillis,
    mainAxisTrackInset: Dp = ScrollbarDefaults.MainAxisTrackInset,
    crossAxisTrackInset: Dp = ScrollbarDefaults.CrossAxisTrackInset,
): Modifier

state: ScrollIndicatorState?Required

the ScrollIndicatorState that represents the scroll state. If null, the scrollbar will not be drawn.

orientation: OrientationRequired

the orientation of the scrollbar.

thumbColor: ColorOptional

Default: ScrollbarDefaults.thumbColor

the color of the scrollbar thumb.

trackColor: ColorOptional

Default: Color.Transparent

the color of the scrollbar track.

thickness: DpOptional

Default: ScrollbarDefaults.Thickness

the thickness of the scrollbar.

thumbMinLength: DpOptional

Default: ScrollbarDefaults.ThumbMinLength

the minimum length of the scrollbar thumb. Note that the scrollbar will not be shown if the available track length is less than this minimum length.

thumbMaxLengthFraction: FloatOptional

Default: ScrollbarDefaults.ThumbMaxLengthFraction

the maximum length of the scrollbar thumb as a fraction of the viewport length. This should be between 0f and 1f.

isFadeEnabled: BooleanOptional

Default: true

whether the fade behavior is enabled. If enabled, the scrollbar will be shown when scrolling is active, and fades out after a delay when scrolling is idle. If disabled, the scrollbar remains always visible.

fadeDurationMillis: IntOptional

Default: ScrollbarDefaults.ThumbFadeDurationMillis

the duration of the fade animation in milliseconds.

fadeDelayMillis: IntOptional

Default: ScrollbarDefaults.ThumbFadeDelayMillis

the delay before the scrollbar fades out in milliseconds.

mainAxisTrackInset: DpOptional

Default: ScrollbarDefaults.MainAxisTrackInset

the inset to apply to the scrollbar track along the main axis.

crossAxisTrackInset: DpOptional

Default: ScrollbarDefaults.CrossAxisTrackInset

the inset to apply to the scrollbar track along the cross axis.

Library docs

A scrollbar that represents the current scroll position of a scrolling component.

This scrollbar cannot be interacted with to scroll the component, it is a visual only representation of the scroll position. It is drawn at the end edge (respecting layout direction) for a vertically scrollable component, and at the bottom edge for a horizontally scrollable component.

The scrollbar is only visible if the content size is strictly greater than the viewport size. By default, the scrollbar is shown when scrolling is active and fades out after a delay when scrolling stops. This fading behavior can be disabled by setting isFadeEnabled to false, in which case the scrollbar remains always visible.

To use a scrollbar with a androidx.compose.foundation.lazy.LazyColumn, see: