Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jetpack compose Scaffolds TopAppBar elevation

Trying to add elevation to my TopAppBar in Scaffold topBar. Using Jetpack compose, material 3.

This is how it worked before:

TopAppBar(
        title = {
            Text(text = title)
        },
        elevation = 3.dp //Not valid anymore
    )

Current allowed parameters in TopAppBar are:

public fun TopAppBar(
    title: @Composable () -> Unit,
    modifier: Modifier,
    navigationIcon: @Composable () -> Unit,
    actions: @Composable() (RowScope.() -> Unit),
    windowInsets: WindowInsets,
    colors: TopAppBarColors,
    scrollBehavior: TopAppBarScrollBehavior?
): Unit

This is what I have:

No elevation

This is what I need:

Have elevation

It could be done before using parameter to pass elevation but that is not option anymore.

What would be solution to elevate whole TopAppBar? Thanks in advance!

like image 979
Domagoj Ratko Avatar asked Jun 05 '26 17:06

Domagoj Ratko


1 Answers

Have you tried it with a surface..?

Scaffold(topBar = {
    Surface(shadowElevation = 3.dp) {
        SmallTopAppBar(title = {
            Text(
                text = "title"
            )
        })
    }
}) {
// Content
}

Check the output :

Screenshot

like image 55
SURYA S R Avatar answered Jun 07 '26 08:06

SURYA S R



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!