StylishSwitch

fun StylishSwitch(checked: Boolean, onCheckedChange: (Boolean) -> Unit?, modifier: Modifier = Modifier, enabled: Boolean = true, colors: SwitchColors = SwitchDefaults.colors(), interactionSource: MutableInteractionSource? = null)

A toggle switch for turning a single option on or off, wrapping the Material 3 Switch so it can be themed consistently with the rest of Stylish UI. Use a switch when the change takes effect immediately (e.g. enabling a setting); for mutually exclusive choices prefer StylishRadioButton, and for independent yes/no marks prefer StylishCheckbox.

Parameters

checked

Whether the switch is currently on.

onCheckedChange

Called with the new state when the user toggles the switch. null makes the switch display-only.

modifier

Modifier applied to the Switch root. The root carries the default test tag stylish_switch for UI tests; callers can override it by passing their own Modifier.testTag(...) here.

enabled

When false, the switch ignores pointer input and renders in the disabled color scheme.

colors

Colors used in each state. Defaults to SwitchDefaults.colors.

interactionSource

The MutableInteractionSource for the switch, used to observe press/focus/hover interactions. When null, an internal one is remembered.

See also