Button

fun Button(onClick: () -> Unit, enabled: Boolean = true, shape: Shape = RectangleShape, backgroundColor: Color = Color.Unspecified, contentColor: Color = LocalContentColor.current, contentPadding: PaddingValues = NoPadding, borderColor: Color = Color.Unspecified, borderWidth: Dp = 0.dp, modifier: Modifier = Modifier, role: Role = Role.Button, indication: Indication? = LocalIndication.current, interactionSource: MutableInteractionSource? = null, horizontalArrangement: Arrangement.Horizontal = Arrangement.Center, verticalAlignment: Alignment.Vertical = Alignment.CenterVertically, content: @Composable RowScope.() -> Unit)

An accessible clickable component used to create buttons with the styling of your choice.

For interactive preview & code examples, visit Button Documentation.

Basic Example

Button(
onClick = { /* TODO */},
backgroundColor = Color(0xFFFFFFFF),
contentColor = Color(0xFF020817),
contentPadding = PaddingValues(horizontal = 16.dp, vertical = 12.dp),
shape = RoundedCornerShape(12.dp),
) {
Text("Submit")
}

Parameters

onClick

The callback to be invoked when the button is clicked.

modifier

Modifier to be applied to the button.

enabled

Whether the button is enabled.

shape

The shape of the button.

backgroundColor

The background color of the button.

contentColor

The color to apply to the contents of the button.

contentPadding

Padding values for the content.

borderColor

The color of the border. Applied only if both borderColor is specified and borderWidth is 0.dp

borderWidth

The width of the border. Applied only if both borderColor is specified and borderWidth is 0.dp

role

The role of the button for accessibility purposes.

indication

The indication to be shown when the button is interacted with.

interactionSource

The interaction source for the button.

verticalAlignment

The vertical alignment of the button's children.

horizontalArrangement

The horizontal arrangement of the button's children.

content

A composable function that defines the content of the button.