Search code examples
androidandroid-jetpack-composeandroid-jetpack-compose-material3material3

Jetpack Compose - Reduce Material3 TopAppBar Height


I am migrating my code from Material2 to Material3. The TopAppBar in Material3 has a larger height than Material2, which is not what I want. I have tried reducing the height using the following without success:

  • Setting the window insets to zero does nothing: windowInsets = WindowInsets(top = 0.dp, bottom = 0.dp)
  • Setting the modifier height just made the text inside the bar align to the top of the screen: modifier = Modifier.height(56.dp)

I cannot duplicate and modify the source code because there are too many internal functions and classes for it to be feasible.


Solution

  • This will reduce the height to the original material design height and the text inside the bar will remain vertically centered:

    TopAppBar(
        // required parameters,
        modifier = Modifier.heightIn(max = 56.dp),
    )