pub struct Accordion<S> { /* private fields */ }Expand description
A stack of sections, each a native <details> whose <summary> opens
and closes it.
The browser handles the keyboard and announces each summary as a button
that is expanded or collapsed, and the find-in-page search opens a closed
section that holds a match. An exclusive accordion gives its sections one
name, so the browser closes the open one when another opens.
use hypersig::Signals;
use hypersig::html::p;
use hypersig_ui::Accordion;
use serde::{Deserialize, Serialize};
#[derive(Signals, Serialize, Deserialize)]
struct Faq {}
let faq = Accordion::<Faq>::exclusive("faq")
.item("Is it accessible?", p().text("It follows the WAI-ARIA patterns."))
.item("Is it styled?", p().text("It looks like shadcn/ui."));
assert!(faq.render().render().contains(r#"name="faq""#));Implementations§
Source§impl<S> Accordion<S>
impl<S> Accordion<S>
Sourcepub fn exclusive(name: &'static str) -> Self
pub fn exclusive(name: &'static str) -> Self
An accordion that keeps at most one section open, grouped by name.
Sections with the same name close each other wherever they are on
the page, as radio buttons with one name do, and nothing checks that
each name is used once.
§Panics
Panics if name is empty or holds a character other than an ASCII
letter, digit, -, or _.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for Accordion<S>
impl<S> RefUnwindSafe for Accordion<S>
impl<S> Send for Accordion<S>
impl<S> Sync for Accordion<S>
impl<S> Unpin for Accordion<S>
impl<S> UnsafeUnpin for Accordion<S>
impl<S> UnwindSafe for Accordion<S>
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