Button

fun Button(text: String, onClick: () -> Unit, modifier: Modifier = Modifier, buttonType: ButtonType = ButtonType.Primary, buttonSize: ButtonSize = ButtonSize.Medium, icon: Painter? = null, isEnabled: Boolean = true, isLoading: Boolean = false, contentDescription: String? = null, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() })

A button should lead the user to a certain action. Unique labels give the user a clear message which action is exactly triggered.

For more information visit the ODS Core Documentation

Button Sample

States

The button can be in different states that can be toggled with the isEnabled and isLoading parameters.

Loading

Loading Button Sample

Disabled

Disabled Button Sample

Parameters

text

The text to be displayed in the button.

onClick

The Lambda to be invoked when the button is clicked.

modifier

An optional Modifier to be applied to the button. Defaults to Modifier.

buttonType

An optional ButtonType to be applied to the button. Defaults to ButtonType.Primary.

buttonSize

An optional ButtonSize to be applied to the button. Defaults to ButtonSize.Medium.

icon

An optional icon to be displayed at the start (ButtonType.Primary, ButtonType.Secondary) or the end (ButtonType.Tertiary) of the button.

isEnabled

Whether the button is enabled or not. Defaults to true.

isLoading

Whether the button is loading or not. Defaults to false.

contentDescription

An optional content description for accessibility. If not provided, text will be used.

interactionSource

An optional hoisted MutableInteractionSource for observing and emitting Interactions for the button. You can use this to change the button's appearance or preview the button in different states. Defaults to a remembered MutableInteractionSource.