We just launched Compose Examples featuring over 150+ components! Check it out →

FilledButton

Android

Component in Jetpack Glance

A button styled per Material3. It has a filled background. It is more opinionated than [Button] and suitable for uses where M3 is preferred.

Last updated:

Installation

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

Overloads

@Composable
fun FilledButton(
    text: String,
    onClick: () -> Unit,
    modifier: GlanceModifier = GlanceModifier,
    enabled: Boolean = true,
    icon: ImageProvider? = null,
    colors: ButtonColors = ButtonDefaults.buttonColors(),
    maxLines: Int = Int.MAX_VALUE,
    key: String? = null
)

Parameters

namedescription
textThe text that this button will show.
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.
iconAn optional leading icon placed before the text.
colorsThe colors to use for the background and content of the button.
maxLinesAn optional maximum number of lines for the text to span, wrapping ifnecessary. If the text exceeds the given number of lines, it will be truncated.
keyA stable and unique key that identifies the action for this button. This ensuresthat the correct action is triggered, especially in cases of items that change order. If notprovided we use the key that is automatically generated by the Compose runtime, which is uniquefor every exact code location in the composition tree.
@Composable
fun FilledButton(
    text: String,
    onClick: Action,
    modifier: GlanceModifier = GlanceModifier,
    enabled: Boolean = true,
    icon: ImageProvider? = null,
    colors: ButtonColors = ButtonDefaults.buttonColors(),
    maxLines: Int = Int.MAX_VALUE,
)

Parameters

namedescription
textThe text that this button will show.
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.
iconAn optional leading icon placed before the text.
colorsThe colors to use for the background and content of the button.
maxLinesAn optional maximum number of lines for the text to span, wrapping ifnecessary. If the text exceeds the given number of lines, it will be truncated.
by @alexstyl