Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove undeline of TabRow in Jetpack Compose?

I am tiring to remove the underline of TabRow, but did not succeed. Here is the code:

@ExperimentalPagerApi
@Composable
fun Tabs(pagerState: PagerState) {
    val tabs = listOf(R.string.add, R.string.add)
    val scope = rememberCoroutineScope()
    val currentPage = pagerState.currentPage
    TabRow(
        modifier = Modifier
            .padding(start = 36.dp, top = 16.dp, end = 36.dp)
            .clip(shape = RoundedCornerShape(16.dp)),
        selectedTabIndex = currentPage,
        backgroundColor = Color.Transparent,
        tabs = {
            tabs.forEachIndexed { index, tab ->
                Tab(
                    modifier = Modifier.clip(RoundedCornerShape(16.dp)),
                    text = {
                        Text(text = stringResource(id = tab))
                    },
                    selected = currentPage == index,
                    onClick = {
                        scope.launch {
                            pagerState.animateScrollToPage(index)
                        }
                    }
                )
            }
        }
    )
}

enter image description here

I only want to have the selected color.

like image 924
Mark Delphi Avatar asked Feb 02 '26 16:02

Mark Delphi


2 Answers

set divider param of TabRow as divider={}. Default one is

divider: @Composable () -> Unit = @Composable {
    Divider()
}
like image 110
Thracian Avatar answered Feb 05 '26 05:02

Thracian


When using a Scrollable tabRow in material 3 you can remove the underline below the entire scrollable tab row and the indicator for individual selected tabs like this

ScrollableTabRow(
        selectedTabIndex = tabIndex, edgePadding = 16.dp,
        indicator = {

        }, divider = {

        }
    ) { }

removing the tab indicator only

ScrollableTabRow(
        selectedTabIndex = tabIndex, edgePadding = 16.dp,
        indicator = {

        }
    ) { }

and to remove the underline below the entire scrollable tab row

ScrollableTabRow(
        selectedTabIndex = tabIndex, edgePadding = 16.dp,
        divider = {

        }
    ) { }
like image 39
Felix Kariuki Avatar answered Feb 05 '26 07:02

Felix Kariuki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!