Build apps faster with our new App builder! Check it out →

OutlinedIconButton

Android

Component in Wear Material 3 Compose

Wear Material [OutlinedIconButton] is a circular, icon-only button with a transparent background, contrasting icon color and border. It offers a single slot to take an icon or image.

Set the size of the [OutlinedIconButton] with Modifier.[touchTargetAwareSize] to ensure that the recommended minimum touch target size is available.

The recommended icon button sizes are [IconButtonDefaults.DefaultButtonSize], [IconButtonDefaults.LargeButtonSize], [IconButtonDefaults.SmallButtonSize] and [IconButtonDefaults.ExtraSmallButtonSize].

Use [IconButtonDefaults.iconSizeFor] to determine the icon size for a given [IconButtonDefaults] size, or refer to icon sizes [IconButtonDefaults.SmallIconSize], [IconButtonDefaults.DefaultIconSize], [IconButtonDefaults.LargeButtonSize] directly.

[OutlinedIconButton] can be enabled or disabled. A disabled button will not respond to click events.

An [OutlinedIconButton] has a transparent background and a thin border by default with content taking the theme primary color.

Last updated:

Installation

dependencies {
   implementation("androidx.wear.compose:compose-material3:1.0.0-alpha27")
}

Overloads

@Composable
fun OutlinedIconButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    onLongClick: (() -> Unit)? = null,
    onLongClickLabel: String? = null,
    enabled: Boolean = true,
    shapes: IconButtonShapes = IconButtonDefaults.shapes(),
    colors: IconButtonColors = IconButtonDefaults.outlinedIconButtonColors(),
    border: BorderStroke? = ButtonDefaults.outlinedButtonBorder(enabled),
    interactionSource: MutableInteractionSource? = null,
    content: @Composable BoxScope.() -> Unit,
)

Parameters

namedescription
onClickWill be called when the user clicks the button.
modifierModifier to be applied to the button.
onLongClickCalled when this button is long clicked (long-pressed). When this callback is set, [onLongClickLabel] should be set as well.
onLongClickLabelSemantic / accessibility label for the [onLongClick] action.
enabledControls the enabled state of the button. When false, this button will not be clickable.
shapesDefines the shape for this button. Defaults to a static shape based on [IconButtonDefaults.shape], but animated versions are available through [IconButtonDefaults.animatedShapes].
colors[IconButtonColors] that will be used to resolve the background and icon color for this button in different states. See [IconButtonDefaults.outlinedIconButtonColors].
borderOptional [BorderStroke] for the icon button border - [ButtonDefaults.outlinedButtonBorder] by default.
interactionSourcean optional hoisted [MutableInteractionSource] for observing and emitting [Interaction]s for this button. You can use this to change the button's appearance or preview the button in different states. Note that if null is provided, interactions will still happen internally.
contentThe content displayed on the icon button, expected to be icon or image.

Code Example

OutlinedIconButtonSample

@Composable
fun OutlinedIconButtonSample() {
    OutlinedIconButton(onClick = { /* Do something */ }) {
        Icon(imageVector = Icons.Filled.Favorite, contentDescription = "Favorite icon")
    }
}
by @alexstyl