Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decrease padding inside Compose Button

How can I reduce the padding inside the button? I want the text to be closer to the edge of the button

Button(
        onClick = {},
        modifier = Modifier.padding(0.dp),
        shape = RoundedCornerShape(30.dp),
        border = BorderStroke(1.dp, Color(0xFFC4C4C4)),
        colors = ButtonDefaults.buttonColors(
            contentColor = MaterialTheme.colors.onBackground,
            backgroundColor = MaterialTheme.colors.onBackground
        )
    ) {
        Text(
            text = "lorem ipsu",
            fontSize = 13.sp,
            textAlign = TextAlign.Center,
            modifier = Modifier.padding(start = 1.dp, end = 1.dp)
        )

}

like image 329
Wafi_ck Avatar asked Feb 20 '26 04:02

Wafi_ck


1 Answers

You can use contentPadding

Button(
    onClick = {},
    contentPadding = PaddingValues(
        start = 4.dp,
        top = 4.dp,
        end = 4.dp,
        bottom = 4.dp,
    )
) {
    // TODO
}
like image 88
Francesc Avatar answered Feb 21 '26 16:02

Francesc



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!