pub struct ToggleGroup<S, T> { /* private fields */ }Expand description
A group of toggles named label that picks one value of selected.
It follows the WAI-ARIA radio group pattern, since exactly one toggle is
on at a time. The group has role="radiogroup" and each toggle
role="radio" with aria-checked. Tab enters the group at the toggle
whose value selected holds, and the arrow keys, Home, and End move
between toggles and pick the one they reach, through
El::roving_focus. While selected holds a value no toggle has, Tab
skips the group.
use hypersig::Signals;
use hypersig_ui::ToggleGroup;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq)]
enum Align {
Left,
Center,
Right,
}
#[derive(Signals, Serialize, Deserialize)]
struct Text {
align: Align,
}
let align = ToggleGroup::new("Alignment", Text::align())
.item(Align::Left, "Left")
.item(Align::Center, "Center")
.item(Align::Right, "Right");
let html = align.render().render();
assert!(html.contains(r#"role="radiogroup""#));
assert!(html.contains(r#"role="radio""#));Implementations§
Source§impl<S, T: Serialize + PartialEq> ToggleGroup<S, T>
impl<S, T: Serialize + PartialEq> ToggleGroup<S, T>
Sourcepub fn new(label: impl Into<String>, selected: Sig<S, T>) -> Self
pub fn new(label: impl Into<String>, selected: Sig<S, T>) -> Self
An empty group named label for assistive technology.
Sourcepub fn item(self, value: T, text: impl Into<String>) -> Self
pub fn item(self, value: T, text: impl Into<String>) -> Self
Adds a toggle showing text that picks value.
Trait Implementations§
Auto Trait Implementations§
impl<S, T> Freeze for ToggleGroup<S, T>
impl<S, T> RefUnwindSafe for ToggleGroup<S, T>where
T: RefUnwindSafe,
impl<S, T> Send for ToggleGroup<S, T>where
T: Send,
impl<S, T> Sync for ToggleGroup<S, T>where
T: Sync,
impl<S, T> Unpin for ToggleGroup<S, T>where
T: Unpin,
impl<S, T> UnsafeUnpin for ToggleGroup<S, T>
impl<S, T> UnwindSafe for ToggleGroup<S, T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more