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
state: ScrollIndicatorState?Requiredthe ScrollIndicatorState that represents the scroll state. If null, the scrollbar will not be drawn.
orientation: OrientationRequired
orientation: OrientationRequiredthe orientation of the scrollbar.
thumbColor: ColorOptional
thumbColor: ColorOptionalDefault: ScrollbarDefaults.thumbColor
the color of the scrollbar thumb.
trackColor: ColorOptional
trackColor: ColorOptionalDefault: Color.Transparent
the color of the scrollbar track.
thickness: DpOptional
thickness: DpOptionalDefault: ScrollbarDefaults.Thickness
the thickness of the scrollbar.
thumbMinLength: DpOptional
thumbMinLength: DpOptionalDefault: 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
thumbMaxLengthFraction: FloatOptionalDefault: 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
isFadeEnabled: BooleanOptionalDefault: 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
fadeDurationMillis: IntOptionalDefault: ScrollbarDefaults.ThumbFadeDurationMillis
the duration of the fade animation in milliseconds.
fadeDelayMillis: IntOptional
fadeDelayMillis: IntOptionalDefault: ScrollbarDefaults.ThumbFadeDelayMillis
the delay before the scrollbar fades out in milliseconds.
mainAxisTrackInset: DpOptional
mainAxisTrackInset: DpOptionalDefault: ScrollbarDefaults.MainAxisTrackInset
the inset to apply to the scrollbar track along the main axis.
crossAxisTrackInset: DpOptional
crossAxisTrackInset: DpOptionalDefault: 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: