by @alexstyl
✉️ Leave your feedback

← Back to Wear Material 3

OutlinedButton

Component
in
Wear Material 3
. Since 1.0.0-alpha03

Overview

Examples

Community Notes

Video

Base level Wear Material3 OutlinedButton that offers a single slot to take any content. Used as the container for more opinionated OutlinedButton components that take specific content such as icons and labels.

The OutlinedButton is Stadium-shaped by default and has a max height designed to take no more than two lines of text of Typography.labelMedium style. With localisation and/or large font sizes, the text can extend to a maximum of 3 lines in which case, the OutlinedButton height adjusts to accommodate the contents. The OutlinedButton can have an icon or image horizontally parallel to the two lines of text.

OutlinedButton takes the ButtonDefaults.outlinedButtonColors color scheme by default, with a transparent background and a thin border. This is a medium-emphasis button for important, non-primary actions that need attention.

Other recommended buttons with ButtonColors for different levels of emphasis are: Button which defaults to ButtonDefaults.filledButtonColors, FilledTonalButton which defaults to ButtonDefaults.filledTonalButtonColors, ChildButton which defaults to ButtonDefaults.childButtonColors. Buttons can also take an image background using ButtonDefaults.imageBackgroundButtonColors.

Button can be enabled or disabled. A disabled button will not respond to click events.

TODO(b/261838497) Add Material3 UX guidance links

Example of an OutlinedButton:

Overloads

OutlinedButton

@Composable
fun OutlinedButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    shape: Shape = OutlinedButtonTokens.ContainerShape.value,
    colors: ButtonColors = ButtonDefaults.outlinedButtonColors(),
    border: BorderStroke? = ButtonDefaults.outlinedButtonBorder(enabled),
    contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    content: @Composable RowScope.() -> Unit,
)

Parameters

NameDescription
onClickWill be called when the user clicks the button
modifierModifier to be applied to the button
enabledControls the enabled state of the button. When false, this button will not be clickable
shapeDefines the button's shape. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material3 Theme
colorsButtonColors that will be used to resolve the background and content color for this button in different states. See ButtonDefaults.outlinedButtonColors.
borderOptional BorderStroke that will be used to resolve the border for this button in different states. See ButtonDefaults.outlinedButtonBorder.
contentPaddingThe spacing values to apply internally between the container and the content
interactionSourceThe MutableInteractionSource representing the stream of Interactions for this Button. You can create and pass in your own remembered MutableInteractionSource if you want to observe Interactions and customize the appearance / behavior of this Button in different Interactions

OutlinedButton

@Composable
fun OutlinedButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    secondaryLabel: (@Composable RowScope.() -> Unit)? = null,
    icon: (@Composable BoxScope.() -> Unit)? = null,
    enabled: Boolean = true,
    shape: Shape = OutlinedButtonTokens.ContainerShape.value,
    colors: ButtonColors = ButtonDefaults.outlinedButtonColors(),
    border: BorderStroke? = ButtonDefaults.outlinedButtonBorder(enabled),
    contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    label: @Composable RowScope.() -> Unit,
)

Parameters

NameDescription
onClickWill be called when the user clicks the button
modifierModifier to be applied to the button
secondaryLabelA slot for providing the button's secondary label. The contents are expected to be text which is "start" aligned if there is an icon preset and "start" or "center" aligned if not. label and secondaryLabel contents should be consistently aligned.
iconA slot for providing the button's icon. The contents are expected to be a horizontally and vertically aligned icon of size ButtonDefaults.IconSize or ButtonDefaults.LargeIconSize. In order to correctly render when the Button is not enabled, the icon must set its alpha value to LocalContentAlpha.
enabledControls the enabled state of the button. When false, this button will not be clickable
shapeDefines the button's shape. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material3 Theme
colorsButtonColors that will be used to resolve the background and content color for this button in different states. See ButtonDefaults.outlinedButtonColors.
borderOptional BorderStroke that will be used to resolve the button border in different states. See ButtonDefaults.outlinedButtonBorder.
contentPaddingThe spacing values to apply internally between the container and the content
interactionSourceThe MutableInteractionSource representing the stream of Interactions for this Button. You can create and pass in your own remembered MutableInteractionSource if you want to observe Interactions and customize the appearance / behavior of this Button in different Interactions.
labelA slot for providing the button's main label. The contents are expected to be text which is "start" aligned if there is an icon preset and "start" or "center" aligned if not
Previous ComponentMaterialTheme
Next ComponentOutlinedCard