public object AlertDialogDefaults
Contains the default values used by AlertDialog
Properties
VerticalArrangement
public val VerticalArrangement: Arrangement.Vertical =
Arrangement.spacedBy(space = 4.dp, alignment = Alignment.CenterVertically)
Default vertical arrangement for an AlertDialog.
ConfirmIcon
public val ConfirmIcon: @Composable RowScope.() -> Unit = {
Icon(
imageVector = Icons.Check,
contentDescription = getString(Strings.AlertDialogContentDescriptionConfirmButton),
modifier = Modifier.size(28.dp).align(Alignment.CenterVertically),
)
}
Default icon for the confirm button.
DismissIcon
public val DismissIcon: @Composable RowScope.() -> Unit = {
Icon(
imageVector = Icons.Close,
contentDescription = getString(Strings.AlertDialogContentDescriptionDismissButton),
modifier = Modifier.size(28.dp).align(Alignment.CenterVertically),
)
}
Default icon for the dismiss button.
EdgeButtonGestureVisibilityThreshold
public const val EdgeButtonGestureVisibilityThreshold: Float = 0.9f
Recommended gestureVisibilityThreshold for EdgeButton when the primary one-handed gesture is enabled.
ConfirmButtonGestureVisibilityThreshold
public const val ConfirmButtonGestureVisibilityThreshold: Float = 0.9f
Default gestureVisibilityThreshold for ConfirmButton, requiring the button to be more than 90% visible before the primary one-handed gesture is active.
GestureDisabled
public const val GestureDisabled: Float = 0f
Value for gestureVisibilityThreshold on EdgeButton and ConfirmButton that disables the primary one-handed gesture on the button.
Functions
EdgeButton
@Composable
public fun EdgeButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
colors: ButtonColors = ButtonDefaults.buttonColors(),
content: @Composable RowScope.() -> Unit = ConfirmIcon,
)
Default composable for the edge button in an AlertDialog. This is a medium sized EdgeButton. Should be used with AlertDialog overload which contains a single edgeButton slot.
Parameters
| onClick | The callback to be invoked when the button is clicked. |
| modifier | The Modifier to be applied to the button. |
| colors | The ButtonColors to be used for the button. |
| content | The composable content of the button. Defaults to ConfirmIcon. |
EdgeButton
@Composable
public fun EdgeButton(
onClick: () -> Unit,
@FloatRange(from = 0.0, to = 1.0) gestureVisibilityThreshold: Float,
modifier: Modifier = Modifier,
onGestureLabel: String? =
stringResource(
R.string.one_handed_gesture_alert_dialog_primary_action_confirm_accessibility_text
),
colors: ButtonColors = ButtonDefaults.buttonColors(),
content: @Composable RowScope.() -> Unit = ConfirmIcon,
)
Composable for the edge button in an AlertDialog that supports the primary one-handed gesture (OneHandedGestureAction.Primary). This is a medium sized EdgeButton and should be used with the AlertDialog overload that contains a single edgeButton slot when primary gesture activation is desired.
Note: Gesture recognition can be disabled across a component hierarchy by providing false to androidx.wear.compose.material3.onehandedgesture.LocalOneHandedGestureEnabled.
Example of an AlertDialog with a bottom EdgeButton supporting the primary one-handed gesture:
Parameters
| onClick | The callback to be invoked when the button is clicked or triggered via gesture. |
| gestureVisibilityThreshold | The minimum fraction of the button's height, between 0.0 and 1.0, that must be visible before the primary one-handed gesture is active. For values between 0.0 and 1.0, the gesture is active once the visible fraction of the button exceeds the specified threshold. A value of 1f requires the button to reach its full height, whereas GestureDisabled (0f) disables the gesture on the button. Because EdgeButton fades its content out when partially collapsed, EdgeButtonGestureVisibilityThreshold (or a threshold of at least 0.5f) is recommended so the button content and gesture indicator are visible when triggered. |
| modifier | The Modifier to be applied to the button. |
| onGestureLabel | Semantic label used by accessibility services to describe the purpose of the one-handed gesture. Defaults to localized "confirm" text to match ConfirmIcon, and should be customized when content represents a different action. This is highly recommended for ensuring that users with screen readers understand what action will be performed - if null, no accessibility announcement is made for the one-handed gesture. |
| colors | The ButtonColors to be used for the button. |
| content | The composable content of the button. Defaults to ConfirmIcon. |
ConfirmButton
@Composable
public fun ConfirmButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
colors: IconButtonColors = IconButtonDefaults.filledIconButtonColors(),
content: @Composable RowScope.() -> Unit = ConfirmIcon,
)
Default composable for the confirm button in an AlertDialog, which supports the primary one-handed gesture (OneHandedGestureAction.Primary) when the button is sufficiently visible. Should be used with AlertDialog overload which has 2 button slots to confirm or dismiss the action.
Parameters
| onClick | The callback to be invoked when the button is clicked or triggered via gesture. |
| modifier | The Modifier to be applied to the button. |
| colors | The IconButtonColors to be used for the button. |
| content | The composable content of the button. Defaults to ConfirmIcon. |
ConfirmButton
@Composable
public fun ConfirmButton(
onClick: () -> Unit,
@FloatRange(from = 0.0, to = 1.0) gestureVisibilityThreshold: Float,
modifier: Modifier = Modifier,
onGestureLabel: String? =
stringResource(
R.string.one_handed_gesture_alert_dialog_primary_action_confirm_accessibility_text
),
colors: IconButtonColors = IconButtonDefaults.filledIconButtonColors(),
content: @Composable RowScope.() -> Unit = ConfirmIcon,
)
Composable for the confirm button in an AlertDialog with a configurable visibility threshold for the primary one-handed gesture (OneHandedGestureAction.Primary). Should be used with the AlertDialog overload which has 2 button slots to confirm or dismiss the action.
Note: Gesture recognition can also be disabled across a component hierarchy by providing false to androidx.wear.compose.material3.onehandedgesture.LocalOneHandedGestureEnabled.
Example of an AlertDialog where the one-handed gesture on ConfirmButton is disabled by setting gestureVisibilityThreshold to GestureDisabled:
Parameters
| onClick | The callback to be invoked when the button is clicked or triggered via gesture. |
| gestureVisibilityThreshold | The minimum fraction of the button, between 0.0 and 1.0, that must be visible in the viewport before the primary one-handed gesture is active. For values between 0.0 and 1.0, the gesture is active once the visible fraction of the button exceeds the specified threshold. A value of 1f requires the entire button to be visible, whereas GestureDisabled (0f) disables the gesture on the button. ConfirmButtonGestureVisibilityThreshold is used by default in the ConfirmButton overload that does not take a gestureVisibilityThreshold parameter. |
| modifier | The Modifier to be applied to the button. |
| onGestureLabel | Semantic label used by accessibility services to describe the purpose of the one-handed gesture. Defaults to localized "confirm" text to match ConfirmIcon, and should be customized when content represents a different action. This is highly recommended for ensuring that users with screen readers understand what action will be performed - if null, no accessibility announcement is made for the one-handed gesture. |
| colors | The IconButtonColors to be used for the button. |
| content | The composable content of the button. Defaults to ConfirmIcon. |
DismissButton
@Composable
public fun DismissButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
colors: IconButtonColors = IconButtonDefaults.filledTonalIconButtonColors(),
content: @Composable RowScope.() -> Unit = DismissIcon,
)
Default composable for the dismiss button in an AlertDialog. Should be used with AlertDialog overload which has 2 button slots to confirm or dismiss the action.
Parameters
| onClick | The callback to be invoked when the button is clicked. |
| modifier | The Modifier to be applied to the button. |
| colors | The IconButtonColors to be used for the button. |
| content | The composable content of the button. Defaults to DismissIcon. |
confirmDismissContentPadding
@Composable
public fun confirmDismissContentPadding(): PaddingValues
The padding to apply around the content for the AlertDialog variation with confirm dismiss buttons and no icon content.
confirmDismissWithIconContentPadding
@Composable
public fun confirmDismissWithIconContentPadding(): PaddingValues
The padding to apply around the content for the AlertDialog variation when an icon is provided and with confirm dismiss buttons.
contentPadding
@Composable
public fun contentPadding(): PaddingValues
The padding to apply around the content for the AlertDialog with either a stack of buttons (no confirm or dismiss buttons) or an EdgeButton, and when there is no icon. For the EdgeButton variation, the bottom padding is ignored.
contentWithIconPadding
@Composable
public fun contentWithIconPadding(): PaddingValues
The padding to apply around the content for the AlertDialog with either a stack of buttons (no confirm or dismiss buttons) or an EdgeButton, and when there is an icon. For the EdgeButton variation, the bottom padding is ignored.
buttonStackContentPadding
@Composable
public fun buttonStackContentPadding(isScrollable: Boolean): PaddingValues
The padding to apply around the content for the AlertDialog variation using TransformingLazyColumn, without an icon, and with a stack of buttons for options. Bottom padding is calculated based on the provided isScrollable parameter, which favors the use of a bigger padding for scrollable content and a smaller one for fixed content.
buttonStackWithIconContentPadding
@Composable
public fun buttonStackWithIconContentPadding(isScrollable: Boolean): PaddingValues
The padding to apply around the content for the AlertDialog variation using TransformingLazyColumn, with icon, and with a stack of buttons for options. Bottom padding is calculated based on the provided isScrollable parameter, which favors the use of a bigger padding for scrollable content and a smaller one for fixed content.
GroupSeparator
@Composable
public fun GroupSeparator()
Separator for the AlertDialog. Should be used inside AlertDialog content for splitting groups of elements.