DraggableTabRow
fun DraggableTabRow(state: PagerState, modifier: Modifier = Modifier, backgroundColor: Color = MaterialTheme.colors.primarySurface, indicatorColor: Color = MaterialTheme.colors.primary, shapeRadius: Dp = 16.dp, content: @Composable RowScope.() -> Unit)
A TabRow contains a row of Tabs, and displays an indicator underneath the currently selected tab. A TabRow places its tabs evenly spaced along the entire row, with each tab taking up an equal amount of space.
DraggableTabRow(
modifier = Modifier.fillMaxWidth(),
backgroundColor = Color(0xFF21354F),
indicatorColor = Color(0xFF40BED0),
state = pagerState
) {
tabItems.mapIndexed { index, text ->
Tab(
selected = index == pagerState.currentPage,
text = { Text(text = text) },
onClick = {
coroutineScope.launch {
pagerState.animateScrollToPage(index)
}
}
)
}
}
Content copied to clipboard
Parameters
state
The state to control this pager
modifier
optional Modifier for this indicator
backgroundColor
The background color for the DraggableTabRow. Use Color. Transparent to have no color.
indicatorColor
The color for the draggable indicator.
shapeRadius
Defines the tab's shape.
content
the content of this tab row