public object ToggleButtonDefaults
Contains default values used by ToggleButtons.
Properties
CheckedShape
public val CheckedShape: Shape = RoundedCornerShape(20.dp)
Default shape for ToggleButton in the checked state.
Functions
contentPadding
@Composable
public fun contentPadding(buttonSize: ButtonSize): PaddingValues
Default content padding used for a ToggleButton with the specified buttonSize.
shape
@Composable
public fun shape(
checked: Boolean,
checkedShape: Shape = CheckedShape,
uncheckedShape: Shape = GlimmerTheme.shapes.large,
): Shape
Chooses a Shape based on the checked state and can be used to override the default Glimmer button shapes. Note that it simply switches shapes without animation.
If you require an animated version, please refer to ToggleButtonDefaults.animatedShape, which uses default Glimmer animations and shapes, or consider creating a custom animated shape.
Parameters
| checked | whether the button is in the checked state |
| checkedShape | the shape of the button when it is checked |
| uncheckedShape | the shape of the button when it is unchecked |
animatedShape
@Composable
public fun animatedShape(checked: Boolean): Shape
Provides a Shape that uses the default Glimmer shapes for buttons and animates transitions between states. If you require an animated transition between your own custom shapes, please consider creating a custom animated shape.
Parameters
| checked | whether the button is in the checked state |
colors
@Composable
public fun colors(
backgroundColor: Color = GlimmerTheme.colors.surface,
focusedBackgroundColor: Color = calculateFocusedBackgroundColor(backgroundColor),
checkedBackgroundColor: Color =
calculateCheckedBackgroundColor(GlimmerTheme.colors.primary),
focusedCheckedBackgroundColor: Color =
calculateFocusedCheckedBackgroundColor(checkedBackgroundColor),
contentColor: Color = calculateContentColor(backgroundColor),
focusedContentColor: Color = calculateContentColor(focusedBackgroundColor),
checkedContentColor: Color = calculateContentColor(checkedBackgroundColor),
focusedCheckedContentColor: Color = calculateContentColor(focusedCheckedBackgroundColor),
): ToggleButtonColors
Creates ToggleButtonColors with default values for a ToggleButton.
Parameters
| backgroundColor | the background color when the button is unchecked and unfocused |
| focusedBackgroundColor | the background color when the button is unchecked and focused. Defaults to a color derived from backgroundColor |
| checkedBackgroundColor | the background color when the button is checked and unfocused |
| focusedCheckedBackgroundColor | the background color when the button is checked and focused. Defaults to a color derived from checkedBackgroundColor |
| contentColor | the content color when the button is unchecked and unfocused |
| focusedContentColor | the content color when the button is unchecked and focused |
| checkedContentColor | the content color when the button is checked and unfocused |
| focusedCheckedContentColor | the content color when the button is checked and focused |
calculateFocusedBackgroundColor
public fun calculateFocusedBackgroundColor(seedColor: Color): Color
Derives a color suitable for use as the unchecked, focused background color of a ToggleButton from the provided seedColor.
Parameters
| seedColor | the base Color from which the focused background color will be derived, typically the unchecked, unfocused background color of the button |
Return
a color to be used as the background Color for the button when unchecked and focused
calculateCheckedBackgroundColor
public fun calculateCheckedBackgroundColor(seedColor: Color): Color
Derives a color suitable for use as the checked, unfocused background color of a ToggleButton from the provided seedColor.
Parameters
| seedColor | the base Color from which the checked background color will be derived, typically a contrasting color such as a brand or accent color |
Return
a color to be used as the background Color for the button when checked and unfocused
calculateFocusedCheckedBackgroundColor
public fun calculateFocusedCheckedBackgroundColor(seedColor: Color): Color
Derives a color suitable for use as the focused, checked background color of a ToggleButton from the provided seedColor.
Parameters
| seedColor | the base Color from which the focused, checked background color will be derived, typically a contrasting color such as a brand or accent color |
Return
a color to be used as the background Color for the button when focused and checked