Jetpack Compose Material 3 has five button types: Button (filled), FilledTonalButton, ElevatedButton, OutlinedButton and TextButton. Each one takes an onClick lambda and a content slot, and they differ in emphasis, from the strongest call to action to a quiet text link. This guide explains the jetpack compose button choices, their parameters and how to pick the right one.
Compose also provides icon buttons and the floating action button family, which are covered at the end.
All of them live in androidx.compose.material3. The content slot is a lambda, so a button can hold text, an icon or both.
| Button | Emphasis | Typical use |
|---|---|---|
Button | Highest | The main action of a screen, such as Save or Continue |
FilledTonalButton | Medium to high | Important but secondary action, such as Add to cart next to Buy now |
ElevatedButton | Medium | Actions on a busy or patterned background, where a shadow separates the button |
OutlinedButton | Medium to low | Secondary actions such as Cancel or Back |
TextButton | Lowest | Dialog actions, inline actions and less important choices |
Material guidance is to use one high-emphasis button per area and to lower the emphasis of the others.
onClick is a plain lambda. Keep logic small there and call into a ViewModel for real work.
The enabled parameter turns a button off. A disabled button does not respond to clicks and is drawn with reduced contrast.
Computing enabled from state is the Compose way of validating a form. You never change the button object. You change the state and the UI follows.
The content lambda is a RowScope, so you can place an icon and text side by side.
Each type has its own defaults object with matching colour helpers: ButtonDefaults.buttonColors, filledTonalButtonColors, elevatedButtonColors, outlinedButtonColors and textButtonColors. OutlinedButton also accepts a border parameter. The icon has contentDescription = null because the text next to it already describes the action.
Prefer theme colours (MaterialTheme.colorScheme) over fixed colours so dark mode and dynamic colour keep working.
For a single icon without text, use an icon button. The default IconButton has no container, while FilledIconButton, FilledTonalIconButton and OutlinedIconButton add one.
An icon-only button needs a real contentDescription because there is no text.
Floating action buttons (FloatingActionButton, SmallFloatingActionButton, LargeFloatingActionButton and ExtendedFloatingActionButton) highlight the single main action of a screen and are normally passed to the floatingActionButton slot of Scaffold.
Buttons have a minimum touch target of 48 dp, and Compose enforces it by default even when the visible button is smaller. Do not shrink it with a tiny Modifier.size. Keep labels short, action-based and written in sentence case, such as "Save changes". Pair colour with text or an icon, so meaning does not depend on colour alone.
Button uses the strongest primary colour for the main action. FilledTonalButton uses a softer container colour and suits an important but secondary action.
Pass enabled = false. Drive that value from state, for example from form validation.
Put an Icon, a Spacer and a Text inside the content lambda, which is laid out as a Row. Use ButtonDefaults.IconSize and IconSpacing for correct spacing.
It still exists in the Material 2 artifact, but new apps should use androidx.compose.material3. Do not mix both in one theme.
Material 3 offers Button, FilledTonalButton, ElevatedButton, OutlinedButton and TextButton, ordered from high to low emphasis. Use one prominent button per area, control state with enabled, add icons in the content slot, and style them through ButtonDefaults and the theme. Use icon buttons and FABs for icon-only and main-screen actions, with proper content descriptions.