Button
@Composable
Basic button component.
Since
0.2.0
Example:
Button(
style =
StyleDefaults.style(
colors =
StyleDefaults.colors(
backgroundColor = Color.Black,
contentColor = Color.White,
focusedBackgroundColor = Color.Red,
focusedContentColor = Color.Black,
pressedBackgroundColor = Color.Black.copy(alpha = .6f),
),
scale = StyleDefaults.scale(focusedScale = 1.2f),
shapes = StyleDefaults.shapes(RoundedCornerShape(12.dp)),
),
modifier = modifier.width(200.dp),
onClick = onClick,
) {
val color = LocalContentColor.current
BasicText(text = title, color = { color })
}
Content copied to clipboard
Parameters
onClick
Callback to be invoked when the button is clicked.
modifier
Modifier to be applied to the layout corresponding to the surface.
enabled
Whether the button is enabled.
onLongClick
Callback to be invoked when the button is long clicked.
style
The style of the button.
contentPadding
PaddingValues to be set on the inner content.
interactionSource
Optional MutableInteractionSource for observing and emitting Interactions.
content
Defines the Composable content inside the button.