Skip to content

Toggle

A pressable control that retains an on or off pressed state.

Loading interactive demo…

#Import

Import Toggle from quickgui.

use quickgui::*;

#Usage

Toggle::new(pressed)
    .root().on_click(toggle).child("Pin this item")

#Anatomy

  • Toggle::root
  • Toggle::indicator

#API reference

Expand an entry for its description and complete signature. A dash means no declaration default is documented.

pub const fn new(pressed: bool) -> Self
is_pressedpub const fn is_pressed(self) -> bool—

Configures is pressed for this part.

pub const fn is_pressed(self) -> bool
View source

Toggle::root_with

View source
pub fn root_with(self, root: Element) -> Element

Decorate an application-owned root without adding layout or appearance.

Toggle::root

View source
pub fn root(self) -> Element

Create the unstyled root part. Use [`Self::root_with`] to supply an existing element.

Toggle::indicator_with

View source
pub fn indicator_with(self, indicator: Element) -> Element

Hide an application-owned decorative indicator from the accessible name.

Toggle::indicator

View source
pub fn indicator(self) -> Element

Create the unstyled indicator part. Use [`Self::indicator_with`] to supply an existing element.

pub fn toggle(pressed: bool) -> Element

Create an unstyled controlled toggle-button root. This shorthand is equivalent to `Toggle::new(pressed).root_with(div())`.