Buttons in Jetpack Compose (Material 3) come in five types and are easy to style: change colors with ButtonDefaults.buttonColors, the corners with shape, the size with Modifier and contentPadding, and add an icon next to the text. This guide covers each with Kotlin examples.

Page Contents
The 5 Material 3 button types
| Composable | Emphasis | Use for |
|---|---|---|
Button | Highest (filled) | The main action: Save, Continue, Buy |
FilledTonalButton | Medium-high | Important but secondary actions |
ElevatedButton | Medium | When the button needs to stand out from a patterned background |
OutlinedButton | Medium-low | Secondary actions: Cancel, Back |
TextButton | Lowest | Dialog actions, “Learn more” links |
Button(onClick = { /* save */ }) { Text("Save") }
FilledTonalButton(onClick = { }) { Text("Tonal") }
ElevatedButton(onClick = { }) { Text("Elevated") }
OutlinedButton(onClick = { }) { Text("Cancel") }
TextButton(onClick = { }) { Text("Learn more") }Button with icon and text
Put an Icon, a Spacer and the Text inside the button. ButtonDefaults.IconSize and ButtonDefaults.IconSpacing give the Material spacing, and ButtonWithIconContentPadding balances the padding:
Button(
onClick = { /* share */ },
contentPadding = ButtonDefaults.ButtonWithIconContentPadding
) {
Icon(
Icons.Filled.Share,
contentDescription = null,
modifier = Modifier.size(ButtonDefaults.IconSize)
)
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
Text("Share")
}Icon after the text? Swap the order: Text, Spacer, then Icon. Icon only? Use IconButton or FilledIconButton.
Change button colors
Button(
onClick = { },
colors = ButtonDefaults.buttonColors(
containerColor = Color(0xFF3D63E6),
contentColor = Color.White,
disabledContainerColor = Color(0xFFE4E6EE),
disabledContentColor = Color(0xFF8A90A8)
)
) { Text("Continue") }Each type has its own helper: filledTonalButtonColors, outlinedButtonColors, elevatedButtonColors and textButtonColors. Better still, set colors once in your MaterialTheme so every button matches.
Change the shape (rounded, pill, square)
Button(onClick = { }, shape = RoundedCornerShape(8.dp)) { Text("8 dp corners") }
Button(onClick = { }, shape = CircleShape) { Text("Pill") }
Button(onClick = { }, shape = RectangleShape) { Text("Square") }Border, size and padding
OutlinedButton(
onClick = { },
border = BorderStroke(2.dp, Color(0xFF3D63E6)),
contentPadding = PaddingValues(horizontal = 24.dp, vertical = 14.dp),
modifier = Modifier
.fillMaxWidth()
.height(56.dp)
) { Text("Full-width button") }Disabled and loading buttons
var loading by remember { mutableStateOf(false) }
Button(onClick = { loading = true }, enabled = !loading) {
if (loading) {
CircularProgressIndicator(
modifier = Modifier.size(18.dp),
strokeWidth = 2.dp,
color = LocalContentColor.current
)
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
Text("Saving…")
} else {
Text("Save")
}
}Gradient background button
Material buttons use a solid container color. For a gradient, make the container transparent and draw the gradient behind the content:
Button(
onClick = { },
colors = ButtonDefaults.buttonColors(containerColor = Color.Transparent),
contentPadding = PaddingValues(),
shape = RoundedCornerShape(12.dp)
) {
Box(
modifier = Modifier
.background(Brush.horizontalGradient(listOf(Color(0xFF3D63E6), Color(0xFF8B5CF6))))
.padding(horizontal = 24.dp, vertical = 12.dp),
contentAlignment = Alignment.Center
) { Text("Get started", color = Color.White) }
}FAQ
How do I change the button color in Jetpack Compose?
Pass colors = ButtonDefaults.buttonColors(containerColor = …, contentColor = …) to the Button.
How do I make a rounded button?
Set shape = RoundedCornerShape(16.dp), or CircleShape for a pill shape.
How do I add an icon to a button?
Place an Icon and a Spacer before the Text inside the button, sized with ButtonDefaults.IconSize and ButtonDefaults.IconSpacing.
More Jetpack Compose guides
- Toggle buttons in Jetpack Compose
- Text in Jetpack Compose
- Clickable text and links
- TextField in Jetpack Compose
