IconButton

Functions summary

Unit
@Composable
IconButton(
    onClick: () -> Unit,
    modifier: Modifier,
    enabled: Boolean,
    shape: Shape,
    color: Color,
    contentColor: Color,
    border: BorderStroke?,
    contentPadding: PaddingValues,
    interactionSource: MutableInteractionSource?,
    content: @Composable () -> Unit
)

IconButton is a component used for exposing supplementary actions with a single tap.

Functions

IconButton

@Composable
fun IconButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    shape: Shape = GlimmerTheme.shapes.large,
    color: Color = GlimmerTheme.colors.surface,
    contentColor: Color = calculateContentColor(color),
    border: BorderStroke? = SurfaceDefaults.border(),
    contentPadding: PaddingValues = PaddingValues(GlimmerTheme.componentSpacingValues.small),
    interactionSource: MutableInteractionSource? = null,
    content: @Composable () -> Unit
): Unit

IconButton is a component used for exposing supplementary actions with a single tap.

Icon buttons are used when a compact button is required, such as in a toolbar or image list.

content should typically be an Icon. If using a custom icon, note that the typical size for the internal icon is 32 x 32 dp. Container has an overall minimum size of 48 x 48 dp.

import androidx.xr.glimmer.Icon
import androidx.xr.glimmer.IconButton

IconButton(onClick = {}) { Icon(FavoriteIcon, "Localized description") }
Parameters
onClick: () -> Unit

called when this icon button is clicked

modifier: Modifier = Modifier

the Modifier to be applied to this icon button

enabled: Boolean = true

controls the enabled state of this icon button. When false, this icon button will not respond to user input

shape: Shape = GlimmerTheme.shapes.large

the Shape used to clip this icon button

color: Color = GlimmerTheme.colors.surface

background color of this icon button

contentColor: Color = calculateContentColor(color)

content color used by components inside content

border: BorderStroke? = SurfaceDefaults.border()

the border to draw around this icon button

contentPadding: PaddingValues = PaddingValues(GlimmerTheme.componentSpacingValues.small)

the spacing values to apply internally between the container and the content

interactionSource: MutableInteractionSource? = null

an optional hoisted MutableInteractionSource for observing and emitting Interactions for this icon button. You can use this to change the icon button's appearance or preview the icon button in different states. Note that if null is provided, interactions will still happen internally.

content: @Composable () -> Unit

the content of this icon button, typically an Icon