object MenuDefaults
Contains default values used for DropdownMenu and DropdownMenuItem.
Properties
val TonalElevation = ElevationTokens.Level0
The default tonal elevation for a menu.
val ShadowElevation = MenuTokens.ContainerElevation
The default shadow elevation for a menu.
val LeadingIconSize = SegmentedMenuTokens.ItemLeadingIconSize
The default leading icon size for a menu item.
val TrailingIconSize =
if (shouldUsePrecisionPointerComponentSizing.value) {
24.dp
} else {
SegmentedMenuTokens.ItemTrailingIconSize
}
The default trailing icon size for a menu item.
val shape
The default shape for a menu.
val containerColor
The default container color for a menu.
@ExperimentalMaterial3ExpressiveApi
val groupStandardContainerColor: Color
The standard default container color for a group within a menu.
Menus have two color options: standard (surface based) vibrant (tertiary based)
These mappings provide options for lower or higher visual emphasis. Vibrant menus are more prominent so should be used sparingly.
@ExperimentalMaterial3ExpressiveApi
val groupVibrantContainerColor: Color
The vibrant default container color for a group within a menu.
Menus have two color options: standard (surface based) vibrant (tertiary based)
These mappings provide options for lower or higher visual emphasis. Vibrant menus are more prominent so should be used sparingly.
@ExperimentalMaterial3ExpressiveApi
val leadingGroupShape: Shape
The default shape for the leading group of a menu.
@ExperimentalMaterial3ExpressiveApi
val middleGroupShape: Shape
The default shape for the middle group of a menu.
@ExperimentalMaterial3ExpressiveApi
val trailingGroupShape: Shape
The default shape for the trailing group of a menu.
@ExperimentalMaterial3ExpressiveApi
val leadingItemShape: Shape
The default shape for the leading item of a menu or group.
@ExperimentalMaterial3ExpressiveApi
val middleItemShape: Shape
The default shape for the middle item of a menu or group.
@ExperimentalMaterial3ExpressiveApi
val trailingItemShape: Shape
The default shape for the trailing item of a menu or group.
@ExperimentalMaterial3ExpressiveApi
val standaloneItemShape: Shape
The default shape for a standalone item of a menu or group.
@ExperimentalMaterial3ExpressiveApi
val selectedItemShape: Shape
The selected shape for items of a group.
@ExperimentalMaterial3ExpressiveApi
val standaloneGroupShape: Shape
The default shape for a standalone group of a menu.
@ExperimentalMaterial3ExpressiveApi
val inactiveGroupShape: Shape
The shape for a group of a menu that is no longer being hovered.
@ExperimentalMaterial3ExpressiveApi val GroupSpacing: Dp
The default spacing between each menu group. Usually used in a Spacer's height
@ExperimentalMaterial3ExpressiveApi
val HorizontalDividerPadding: PaddingValues
The default padding for a HorizontalDivider used in a menu group. Use this padding value in a HorizontalDivider's padding modifier.
@ExperimentalMaterial3ExpressiveApi
val DropdownMenuGroupLabelHorizontalPadding = PaddingValues(start = 12.dp, end = 4.dp)
The default horizontal padding for a menu group label. Please see MenuDefaults.Label.
@ExperimentalMaterial3ExpressiveApi
val DropdownMenuItemTrailingLabelHorizontalPadding =
if (shouldUsePrecisionPointerComponentSizing.value) {
PaddingValues(start = 0.dp, end = 6.dp)
} else {
PaddingValues(all = 0.dp)
}
The default horizontal padding for a menu group trailing label. Please see MenuDefaults.DropdownMenuItemTrailingLabel.
val DropdownMenuItemContentPadding =
PaddingValues(horizontal = DropdownMenuItemHorizontalPadding, vertical = 0.dp)
Default padding used for DropdownMenuItem.
val DropdownMenuSelectableItemContentPadding =
if (shouldUsePrecisionPointerComponentSizing.value) {
PaddingValues(
start = 16.dp,
end = 10.dp,
top = SelectableItemVerticalPadding,
bottom = SelectableItemVerticalPadding,
)
} else {
PaddingValues(
horizontal = DropdownMenuItemHorizontalPadding,
vertical = SelectableItemVerticalPadding,
)
}
Default padding used for DropdownMenuItem that are selectable.
val DropdownMenuGroupContentPadding =
PaddingValues(horizontal = 0.dp, vertical = DropdownMenuGroupVerticalPadding)
Default padding used for DropdownMenuGroup.
Functions
groupShape
@ExperimentalMaterial3ExpressiveApi
@Composable
fun groupShape(index: Int, count: Int): MenuGroupShapes
A MenuGroupShapes constructor that the group in index should have when there are count groups in the menu.
Parameters
| index | the index for this group in the menu. |
| count | the count of groups in this menu. |
itemShape
@ExperimentalMaterial3ExpressiveApi
@Composable
fun itemShape(index: Int, count: Int): MenuItemShapes
A MenuItemShapes constructor that the item in index should have when there are count items in the menu or group. If a DropdownMenuGroup is used, please pass the number of items within the group as count. If no DropdownMenuGroup is used, please pass the number of items in the entire menu as count.
Parameters
| index | the index for this item in the menu or group. |
| count | the count of items in this menu or group. |
@Composable fun itemColors(): MenuItemColors
Creates a MenuItemColors that represents the default text and icon colors used in a DropdownMenuItemContent.
itemShapes
@ExperimentalMaterial3ExpressiveApi
@Composable
fun itemShapes(shape: Shape? = null, selectedShape: Shape? = null): MenuItemShapes
Creates a MenuItemShapes that represents the shapes used in a toggleable or selectable DropdownMenuItem, allowing for overrides.
There is a convenience function that can be used to easily determine the shape to be used at MenuDefaults.itemShape.
Parameters
| shape | the shape when unselected. It uses middleItemShape as the default if null is provided. |
| selectedShape | the shape when selected. It uses selectedItemShape as the default if null is provided. |
itemShapes
@ExperimentalMaterial3ExpressiveApi
@Composable
fun itemShapes(): MenuItemShapes
Creates a MenuItemShapes that represents the shapes used in a toggleable or selectable DropdownMenuItem.
There is a convenience function that can be used to easily determine the shape to be used at MenuDefaults.itemShape.
This MenuItemShapes has MenuDefaults.standaloneItemShape as the shape and MenuDefaults.selectedItemShape as the selected shape.
groupShapes
@ExperimentalMaterial3ExpressiveApi
@Composable
fun groupShapes(shape: Shape? = null, inactiveShape: Shape? = null): MenuGroupShapes
Creates a MenuGroupShapes that represents the default shapes used in a DropdownMenuGroup, allowing for overrides.
There is a convenience function that can be used to easily determine the shape to be used at MenuDefaults.groupShape.
Parameters
| shape | the default shape of the group. It uses standaloneGroupShape as the default if null is provided. |
| inactiveShape | the shape when no longer being hovered. It uses inactiveGroupShape as the default if null is provided. |
groupShapes
@ExperimentalMaterial3ExpressiveApi
@Composable
fun groupShapes(): MenuGroupShapes
Creates a MenuGroupShapes that represents the default shapes used in a DropdownMenuGroup.
This MenuGroupShapes has MenuDefaults.standaloneGroupShape as the shape and MenuDefaults.inactiveGroupShape as the inactive shape, the inactive shape is the shape of the group after it is no longer being hovered.
Label
@ExperimentalMaterial3ExpressiveApi
@Composable
fun Label(
contentAlignment: Alignment = Alignment.CenterStart,
padding: PaddingValues = DropdownMenuGroupLabelHorizontalPadding,
content: @Composable () -> Unit,
)
The default label recommended to be used within a DropdownMenuGroup.
Labels can be used to categorize parts of the group or the entire group
Parameters
| contentAlignment | the alignment of the label's content. |
| padding | the padding applied to the label's content. |
| content | the content of the label. |
DropdownMenuItemTrailingLabel
@ExperimentalMaterial3ExpressiveApi
@Composable
fun DropdownMenuItemTrailingLabel(
padding: PaddingValues = DropdownMenuItemTrailingLabelHorizontalPadding,
content: @Composable () -> Unit,
)
The default trailing label recommended to be used within a DropdownMenuItem which can be passed to its trailingIcon param.
Parameters
| padding | the padding applied to the label's content. |
| content | the content of the label. |
LabelWithSupportingText
@ExperimentalMaterial3ExpressiveApi
@Composable
fun LabelWithSupportingText(
supportingText: @Composable () -> Unit,
content: @Composable () -> Unit,
)
Column of a label and its supporting text. Used in a DropdownMenuItem's text parameter when a supporting text is desired.
Parameters
| supportingText | the supporting text of the label. |
| content | the content of the label. |
itemColors
@Composable
fun itemColors(
textColor: Color = Color.Unspecified,
leadingIconColor: Color = Color.Unspecified,
trailingIconColor: Color = Color.Unspecified,
disabledTextColor: Color = Color.Unspecified,
disabledLeadingIconColor: Color = Color.Unspecified,
disabledTrailingIconColor: Color = Color.Unspecified,
): MenuItemColors
Creates a MenuItemColors that represents the default text and icon colors used in a DropdownMenuItemContent.
Parameters
| textColor | the text color of this DropdownMenuItemContent when enabled |
| leadingIconColor | the leading icon color of this DropdownMenuItemContent when enabled |
| trailingIconColor | the trailing icon color of this DropdownMenuItemContent when enabled |
| disabledTextColor | the text color of this DropdownMenuItemContent when not enabled |
| disabledLeadingIconColor | the leading icon color of this DropdownMenuItemContent when not enabled |
| disabledTrailingIconColor | the trailing icon color of this DropdownMenuItemContent when not enabled |
selectableItemColors
@ExperimentalMaterial3ExpressiveApi
@Composable
fun selectableItemColors(
textColor: Color = Color.Unspecified,
containerColor: Color = Color.Unspecified,
leadingIconColor: Color = Color.Unspecified,
trailingIconColor: Color = Color.Unspecified,
disabledTextColor: Color = Color.Unspecified,
disabledLeadingIconColor: Color = Color.Unspecified,
disabledTrailingIconColor: Color = Color.Unspecified,
selectedContainerColor: Color = Color.Unspecified,
selectedTextColor: Color = Color.Unspecified,
selectedLeadingIconColor: Color = Color.Unspecified,
selectedTrailingIconColor: Color = Color.Unspecified,
): MenuItemColors
Creates a MenuItemColors that represents the default text, icon, and container colors used in a standard color variant DropdownMenuItem.
Parameters
| textColor | the text color of this DropdownMenuItem when enabled |
| containerColor | the container color of this DropdownMenuItem when enabled and unselected |
| leadingIconColor | the leading icon color of this DropdownMenuItem when enabled |
| trailingIconColor | the trailing icon color of this DropdownMenuItem when enabled |
| disabledTextColor | the text color of this DropdownMenuItem when not enabled |
| disabledLeadingIconColor | the leading icon color of this DropdownMenuItem when not enabled |
| disabledTrailingIconColor | the trailing icon color of this DropdownMenuItem when not enabled |
| selectedContainerColor | the container color of this DropdownMenuItem when enabled and selected |
| selectedTextColor | the text color of this DropdownMenuItem when enabled and selected |
| selectedLeadingIconColor | the leading icon color of this DropdownMenuItem when enabled and selected |
| selectedTrailingIconColor | the trailing icon color of this DropdownMenuItem when enabled and selected |
selectableItemVibrantColors
@ExperimentalMaterial3ExpressiveApi
@Composable
fun selectableItemVibrantColors(
textColor: Color = Color.Unspecified,
containerColor: Color = Color.Unspecified,
leadingIconColor: Color = Color.Unspecified,
trailingIconColor: Color = Color.Unspecified,
disabledTextColor: Color = Color.Unspecified,
disabledLeadingIconColor: Color = Color.Unspecified,
disabledTrailingIconColor: Color = Color.Unspecified,
selectedContainerColor: Color = Color.Unspecified,
selectedTextColor: Color = Color.Unspecified,
selectedLeadingIconColor: Color = Color.Unspecified,
selectedTrailingIconColor: Color = Color.Unspecified,
): MenuItemColors
Creates a MenuItemColors that represents the default text, icon, and container colors used in a vibrant color variant DropdownMenuItem.
Parameters
| textColor | the text color of this DropdownMenuItem when enabled |
| containerColor | the container color of this DropdownMenuItem when enabled and unselected |
| leadingIconColor | the leading icon color of this DropdownMenuItem when enabled |
| trailingIconColor | the trailing icon color of this DropdownMenuItem when enabled |
| disabledTextColor | the text color of this DropdownMenuItem when not enabled |
| disabledLeadingIconColor | the leading icon color of this DropdownMenuItem when not enabled |
| disabledTrailingIconColor | the trailing icon color of this DropdownMenuItem when not enabled |
| selectedContainerColor | the container color of this DropdownMenuItem when enabled and selected |
| selectedTextColor | the text color of this DropdownMenuItem when enabled and selected |
| selectedLeadingIconColor | the leading icon color of this DropdownMenuItem when enabled and selected |
| selectedTrailingIconColor | the trailing icon color of this DropdownMenuItem when enabled and selected |