Home › Free tools › Jetpack Compose button generator
Free Android dev tool · No signup

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.

All 5 Material 3 button typesDisabled & loading statesImports included
Start from:

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:

ComposableUse it for
ButtonThe main action on a screen (Save, Continue, Buy)
FilledTonalButtonImportant but secondary actions
ElevatedButtonWhen a button must stand out from a patterned background
OutlinedButtonSecondary actions such as Cancel or Back
TextButtonLow-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 as outlinedButtonColors().
  • Shape – shape = RoundedCornerShape(12.dp), CutCornerShape(8.dp) or RectangleShape.
  • 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 Icon with Modifier.size(ButtonDefaults.IconSize) and a Spacer of ButtonDefaults.IconSpacing before the text.

Learning Compose from scratch? Our free Kotlin course covers the language basics you need first.

More free tools you may like

See all 99 free tools →

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

WhatsApp us📞 Call now