Buttons and Clicks
Add interactive buttons.
What Is a Button?
A Button is a tappable composable. When the user taps it, your app runs some code.
Buttons need an onClick action and content to show, usually a Text label.
Button(onClick = { }) {
Text("Tap me")
}The onClick Lambda
The onClick parameter takes a lambda, which is code inside curly braces { }. That code runs each time the button is pressed.
You can put any logic there, like printing or changing data.
Button(onClick = {
println("Clicked!")
}) {
Text("Click")
}All lessons in this course
- Styling Text
- Buttons and Clicks
- Spacing with Padding
- Colors and MaterialTheme