Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Add Elevation to Button? What to Import in Jetpack Compose?

How to add elevation to button? What to import?

@Composable
fun MyUi() {
    Column() {
        Button(onClick = {  }) {
            Text(text = "Lorem")
        }
    }
}
like image 542
Jorpy Avatar asked Oct 19 '25 15:10

Jorpy


1 Answers

To add elevation in your Button composable, you can pass values to the elevation parameter. You can modify your code like below:

@Composable
fun MyUi() {
    Column() {
        Button(
            onClick = {  },
            elevation = ButtonDefaults.buttonElevation(
                defaultElevation = 10.dp
            )
        ) {
            Text(text = "Lorem")
        }
    }
}

Import ButtonDefaults object from androidx.compose.material3.ButtonDefaults

like image 194
Ahsan Ullah Rasel Avatar answered Oct 22 '25 04:10

Ahsan Ullah Rasel



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!