New Compose Multiplatform components arrived on Composables UICheck it out →

SquareIconButton

Intended to fill the role of primary icon button or fab.

Last updated:

Installation

dependencies {
   implementation("androidx.glance:glance-appwidget:1.1.0")
}

Overloads

@Composable
fun SquareIconButton(
    imageProvider: ImageProvider,
    contentDescription: String?,
    onClick: () -> Unit,
    modifier: GlanceModifier = GlanceModifier,
    enabled: Boolean = true,
    backgroundColor: ColorProvider = GlanceTheme.colors.primary,
    contentColor: ColorProvider = GlanceTheme.colors.onPrimary,
    key: String? = null
)

Parameters

namedescription
imageProviderthe icon to be drawn in the button
contentDescriptionText used by accessibility services to describe what this image represents. This text should be localized, such as by using androidx.compose.ui.res.stringResource or similar
onClickThe action to be performed when this button is clicked.
modifierThe modifier to be applied to this button.
enabledIf false, the button will not be clickable.
backgroundColorThe color to tint the button's background.
contentColorThe color to tint the button's icon.
keyA stable and unique key that identifies the action for this button. This ensures that the correct action is triggered, especially in cases of items that change order. If not provided we use the key that is automatically generated by the Compose runtime, which is unique for every exact code location in the composition tree.
@Composable
fun SquareIconButton(
    imageProvider: ImageProvider,
    contentDescription: String?,
    onClick: Action,
    modifier: GlanceModifier = GlanceModifier,
    enabled: Boolean = true,
    backgroundColor: ColorProvider = GlanceTheme.colors.primary,
    contentColor: ColorProvider = GlanceTheme.colors.onPrimary,
)

Parameters

namedescription
imageProviderthe icon to be drawn in the button
contentDescriptionText used by accessibility services to describe what this image represents. This text should be localized, such as by using androidx.compose.ui.res.stringResource or similar
onClickThe action to be performed when this button is clicked.
modifierThe modifier to be applied to this button.
enabledIf false, the button will not be clickable.
backgroundColorThe color to tint the button's background.
contentColorThe color to tint the button's icon.