ButtonKt
public final class ButtonKt
Summary
Public methods |
|
|---|---|
static final void |
@ComposableButton is a component used for exposing actions to a user. |
Public methods
Button
@Composable
public static final void Button(
@NonNull Function0<Unit> onClick,
@NonNull Modifier modifier,
boolean enabled,
@NonNull ButtonSize buttonSize,
@Composable Function0<Unit> leadingIcon,
@Composable Function0<Unit> trailingIcon,
@NonNull Shape shape,
@NonNull Color color,
@NonNull Color contentColor,
BorderStroke border,
@NonNull PaddingValues contentPadding,
MutableInteractionSource interactionSource,
@Composable @NonNull Function1<@NonNull RowScope, Unit> content
)
Button is a component used for exposing actions to a user.
import androidx.xr.glimmer.Button import androidx.xr.glimmer.Text Button(onClick = {}) { Text("Send") }
Buttons can use icons to provide more context about the action:
import androidx.xr.glimmer.Button import androidx.xr.glimmer.Icon import androidx.xr.glimmer.Text Button(onClick = {}, leadingIcon = { Icon(FavoriteIcon, "Localized description") }) { Text("Send") }
There are multiple button size variants - providing a different ButtonSize will affect default values used inside this button, such as the minimum height and the size of icons inside this button. Note that you can still provide a size modifier such as androidx.compose.foundation.layout.size to change the layout size of this button, buttonSize affects default values and values internal to the button.
import androidx.xr.glimmer.Button import androidx.xr.glimmer.ButtonSize import androidx.xr.glimmer.Text Button(onClick = {}, buttonSize = ButtonSize.Large) { Text("Send") }
| Parameters | |
|---|---|
@NonNull Function0<Unit> onClick |
called when this button is clicked |
@NonNull Modifier modifier |
the |
boolean enabled |
controls the enabled state of this button. When |
@NonNull ButtonSize buttonSize |
the size variant of this button, represented as a |
@Composable Function0<Unit> leadingIcon |
optional leading icon to be placed before the |
@Composable Function0<Unit> trailingIcon |
optional trailing icon to be placed after the |
@NonNull Shape shape |
the |
@NonNull Color color |
background color of this button |
@NonNull Color contentColor |
content color used by components inside |
BorderStroke border |
the border to draw around this button |
@NonNull PaddingValues contentPadding |
the spacing values to apply internally between the container and the content |
MutableInteractionSource interactionSource |
an optional hoisted |
@Composable @NonNull Function1<@NonNull RowScope, Unit> content |
the main content, typically |