Jetpack Compose Button generator design it, copy the Kotlin
Pick a Material 3 button type, text, icon, shape, colours and states. See a live preview and copy ready-to-use Compose code – including disabled and loading buttons.
Preview uses the default Material 3 purple theme. In your app the colours come from your theme unless you set custom colours.
Buttons in Jetpack Compose
Material 3 in Compose has five button composables. They all take an onClick lambda and a content slot, so you put a Text (and optionally an Icon) inside the braces:
| Composable | Use it for |
|---|---|
Button | The main action on a screen (Save, Continue, Buy) |
FilledTonalButton | Important but secondary actions |
ElevatedButton | When a button must stand out from a patterned background |
OutlinedButton | Secondary actions such as Cancel or Back |
TextButton | Low-emphasis actions, dialogs and cards |
How to disable a button in Compose
Pass enabled = false. Compose greys the button out and ignores taps – you do not need to change the colours yourself. Usually the value comes from your state, for example a form button that only works once a name is typed:
var name by remember { mutableStateOf("") }
Button(
onClick = { save(name) },
enabled = name.isNotBlank()
) {
Text("Save")
}To control the greyed-out look, set disabledContainerColor and disabledContentColor in ButtonDefaults.buttonColors(). Tick “Custom colours” in the tool to generate this.
Change a button’s colour, shape or size
- Colour –
colors = ButtonDefaults.buttonColors(containerColor = …, contentColor = …). Each button type has its own function, such asoutlinedButtonColors(). - Shape –
shape = RoundedCornerShape(12.dp),CutCornerShape(8.dp)orRectangleShape. - Size – use the modifier:
Modifier.fillMaxWidth().height(52.dp). Keep buttons at least 48 dp tall so they are easy to tap (convert sizes with our dp to px converter). - Icon – add an
IconwithModifier.size(ButtonDefaults.IconSize)and aSpacerofButtonDefaults.IconSpacingbefore the text.
Learning Compose from scratch? Our free Kotlin course covers the language basics you need first.
More free tools you may like
Compose Text Style Generator
Underline, bold, strikethrough and links for Compose Text.
Open tool →Color Converter
HEX, RGB, HSL and CMYK with shades, schemes, contrast and code.
Open tool →App Icon Generator
Every Android, iOS (Xcode) and web icon size from one image, in one ZIP.
Open tool →Store Listing Preview
Character counter and live preview for Google Play and App Store listings.
Open tool →Privacy Policy Generator
A clear privacy policy for apps and websites, with AdMob, Firebase, GDPR and CCPA.
Open tool →AdMob Revenue Calculator
Estimate daily, monthly and yearly ad earnings from users and eCPM.
Open tool →Frequently asked questions
How do I create a button in Jetpack Compose?
Call Button(onClick = { … }) { Text("Save") } inside a composable. The lambda runs when the button is tapped, and whatever you put in the braces is the button’s content.
How do I disable a button in Jetpack Compose?
Set enabled = false. Compose applies the disabled colours and ignores clicks. Use a state value, such as enabled = name.isNotBlank(), to enable it only when the form is ready.
How do I change the button colour in Compose?
Pass colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF3D63E6), contentColor = Color.White). For other types use the matching function, for example outlinedButtonColors() or textButtonColors().
How do I make a full-width button in Compose?
Add modifier = Modifier.fillMaxWidth(). Add .height(48.dp) or more for a taller button.
How do I add an icon to a Compose button?
Put an Icon before the Text inside the button, sized with ButtonDefaults.IconSize and followed by a Spacer of ButtonDefaults.IconSpacing. Material icons need the material-icons-core dependency.
How do I show a loading spinner in a Compose button?
Keep a loading state. While it is true, show a small CircularProgressIndicator inside the button and set enabled = !loading so it cannot be tapped twice. The tool’s “Loading spinner” option writes this code.
What is the difference between Button and TextButton?
Button is filled and is meant for the main action on a screen. TextButton has no background and is for low-emphasis actions like “Cancel” in a dialog.
Need an Android app built?
We design and build Android apps in Kotlin and Jetpack Compose for clients worldwide – clear scope, fixed price, fast delivery.
Techpass Master Technologies · Websites, Android apps and digital marketing
