Skip to main content

icon_toggle

Function icon_toggle 

Source
pub fn icon_toggle<S, R: Writable>(
    label: impl Into<String>,
    pressed: Sig<S, bool, R>,
) -> El<S>
Expand description

A toggle that shows only an icon, named label for assistive technology.

It is toggle with aria-label set to label and a square shape. Add the icon with El::child.

use hypersig::Signals;
use hypersig_ui::icon_toggle;
use serde::{Deserialize, Serialize};

#[derive(Signals, Serialize, Deserialize)]
struct Editor {
    italic: bool,
}

let italic = icon_toggle::<Editor, _>("Italic", Editor::italic()).text("I");
assert!(italic.render().contains(r#"aria-label="Italic""#));