API reference

PrimaryButton Function

Used to convey the most common, recommended action, such as Done or Complete. People trust the primary button in Meta Horizon OS to be the most obvious, usually preferred choice when progressing through any intent.

Signature

fun PrimaryButton(
    label: String,
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    leading: () -> Unit? = null,
    isEnabled: Boolean = true,
    expanded: Boolean = false,
    colors: PrimaryButtonColors = PrimaryButtonDefaults.colors(),
    labelTextStyle: TextStyle?,
    contentAlignment: Alignment.Horizontal = Alignment.CenterHorizontally,
)

Parameters

label: String The text to display on the button.
onClick: () -> Unit The callback to be invoked when the button is clicked.
modifier: Modifier Modifier to be applied to the button.
leading: (() -> Unit)? An optional icon to display before the label.
isEnabled: Boolean Whether the button is enabled or not. Defaults to true.
expanded: Boolean Whether the button should be expanded or not. Defaults to false.
colors: PrimaryButtonColors The colors to use for different states of the button.
labelTextStyle: TextStyle? The text style to be used for the label.
contentAlignment: Alignment.Horizontal The horizontal alignment of the icon and label.