scrollbar
@Composable
fun Modifier.scrollbar(
state: ScrollIndicatorState?,
orientation: Orientation,
thumbColor: Color = ScrollbarDefaults.thumbColor,
trackColor: Color = Color.Transparent,
thickness: Dp = ScrollbarDefaults.Thickness,
thumbMinLength: Dp = ScrollbarDefaults.ThumbMinLength,
@FloatRange(from = 0.0, to = 1.0)
thumbMaxLengthFraction: Float = ScrollbarDefaults.ThumbMaxLengthFraction,
isFadeEnabled: Boolean = true,
fadeDurationMillis: Int = ScrollbarDefaults.ThumbFadeDurationMillis,
fadeDelayMillis: Int = ScrollbarDefaults.ThumbFadeDelayMillis,
mainAxisTrackInset: Dp = ScrollbarDefaults.MainAxisTrackInset,
crossAxisTrackInset: Dp = ScrollbarDefaults.CrossAxisTrackInset,
): Modifier
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:
To use a scrollbar with a androidx.compose.foundation.layout.Column that uses androidx.compose.foundation.verticalScroll, see:
Parameters
| state | the ScrollIndicatorState that represents the scroll state. If null, the scrollbar will not be drawn. |
| orientation | the orientation of the scrollbar. |
| thumbColor | the color of the scrollbar thumb. |
| trackColor | the color of the scrollbar track. |
| thickness | the thickness of the scrollbar. |
| 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 | the maximum length of the scrollbar thumb as a fraction of the viewport length. This should be between 0f and 1f. |
| isFadeEnabled | 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 | the duration of the fade animation in milliseconds. |
| fadeDelayMillis | the delay before the scrollbar fades out in milliseconds. |
| mainAxisTrackInset | the inset to apply to the scrollbar track along the main axis. |
| crossAxisTrackInset | the inset to apply to the scrollbar track along the cross axis. |