Compose Unstyled 2.0 is out! Check the official announcement blog ->
Compose Modifier

scrollbar

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

ScrollbarWithLazyColumnSample

@Composable
fun ScrollbarWithLazyColumnSample() {
    val state = rememberLazyListState()
    LazyColumn(
        state = state,
        modifier =
            Modifier.fillMaxSize()
                .scrollbar(state.scrollIndicatorState, orientation = Orientation.Vertical),
    ) {
        items(100) { index ->
            Text(
                text = "Item $index",
                modifier = Modifier.fillMaxWidth().height(50.dp).wrapContentSize(Alignment.Center),
            )
        }
    }
}

ScrollbarWithVerticalScrollSample

@Composable
fun ScrollbarWithVerticalScrollSample() {
    val state = rememberScrollState()
    Column(
        modifier =
            Modifier.fillMaxSize()
                // Chain before verticalScroll so the scrollbar doesn't scroll with content.
                .scrollbar(state.scrollIndicatorState, orientation = Orientation.Vertical)
                .verticalScroll(state)
    ) {
        repeat(100) { index ->
            Text(
                text = "Item $index",
                modifier = Modifier.fillMaxWidth().height(50.dp).wrapContentSize(Alignment.Center),
            )
        }
    }
}

Last updated: