Skip to content

Glass Switch

rust
pub fn glass_switch(
    args: impl Into<GlassSwitchArgs>,
    state: GlassSwitchState,
)

The glass_switch component is a glass-style switch that toggles between on and off states. It is the glass variant of the switch component. The component supports configuring background color, border, refraction, dispersion, and more, and provides click interaction.

Arguments

  • args: impl Into<GlassSwitchArgs>

    This argument configures the style of the glass_switch component, including size, color, border, etc. Use GlassSwitchArgsBuilder to construct it.

  • state: GlassSwitchState

    This argument manages the state of the glass_switch component, including whether it is currently on or off. GlassSwitchState is a clonable struct that encapsulates a shared reference to the state internally. You can create an initial state with GlassSwitchState::new(bool). Use state.toggle() to toggle the switch state.

Preview

glass_switch

Licensed under the MIT or Apache-2.0 at your option.