ToggleButtonDefaults

object ToggleButtonDefaults


Contains default values used by ToggleButtons.

Summary

Public functions

Shape

Provides a Shape that uses the default Glimmer shapes for buttons and animates transitions between states.

ToggleButtonColors
@Composable
colors(
    backgroundColor: Color,
    checkedBackgroundColor: Color,
    contentColor: Color,
    checkedContentColor: Color
)

Creates ToggleButtonColors with default values for a ToggleButton.

PaddingValues

Default content padding used for a ToggleButton with the specified buttonSize.

Shape
@Composable
shape(checked: Boolean, checkedShape: Shape, uncheckedShape: Shape)

Chooses a Shape based on the checked state and can be used to override the default Glimmer button shapes.

Public properties

Shape

Default shape for ToggleButton and IconToggleButton in the checked state.

Public functions

animateShape

Added in 1.0.0-alpha12
@Composable
fun animateShape(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: Boolean

whether the button is in the checked state

colors

Added in 1.0.0-alpha12
@Composable
fun colors(
    backgroundColor: Color = GlimmerTheme.colors.surface,
    checkedBackgroundColor: Color = GlimmerTheme.colors.outline,
    contentColor: Color = calculateContentColor(backgroundColor),
    checkedContentColor: Color = calculateContentColor(checkedBackgroundColor)
): ToggleButtonColors

Creates ToggleButtonColors with default values for a ToggleButton.

Parameters
backgroundColor: Color = GlimmerTheme.colors.surface

the background color when the button is unchecked

checkedBackgroundColor: Color = GlimmerTheme.colors.outline

the background color when the button is checked

contentColor: Color = calculateContentColor(backgroundColor)

the content color when the button is unchecked

checkedContentColor: Color = calculateContentColor(checkedBackgroundColor)

the content color when the button is checked

contentPadding

Added in 1.0.0-alpha12
@Composable
fun contentPadding(buttonSize: ButtonSize): PaddingValues

Default content padding used for a ToggleButton with the specified buttonSize.

shape

Added in 1.0.0-alpha12
@Composable
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.animateShape, which uses default Glimmer animations and shapes, or consider creating a custom animated shape.

Parameters
checked: Boolean

whether the button is in the checked state

checkedShape: Shape = CheckedShape

the shape of the button when it is checked

uncheckedShape: Shape = GlimmerTheme.shapes.large

the shape of the button when it is unchecked

Public properties

CheckedShape

Added in 1.0.0-alpha12
val CheckedShapeShape

Default shape for ToggleButton and IconToggleButton in the checked state.