How do I tie Tabs and HorizontalPager together? Ac...
# compose
u
How do I tie Tabs and HorizontalPager together? Accompanist used to have
Modifier.pagerTabIndicatorOffset(pagerState
now such api with 1st party APIs?
n
Copy code
var selectedIndex by remember { mutableIntStateOf(0) }
Column {
   TabRow(
    selectedTabIndex = selectedIndex,
    indicator = {
      TabRowDefaults.PrimaryIndicator(
        modifier = Modifier.tabIndicatorOffset(it[selectedIndex]),
        width = 40.dp,
        height = 5.dp,
        color = AppTheme.colors.accent
      )
    }
  ) { ... }
  HorizontalPager(...)
}
u
this doesnt follow the scroll, only jumps to the end states, no?
Copy code
indicator: @Composable @UiComposable
    (tabPositions: List<TabPosition>) -> Unit = @Composable { tabPositions ->
        TabRowDefaults.Indicator(
            Modifier.tabIndicatorOffset(tabPositions[selectedTabIndex])
        )
    },
this is the default anyways