pub struct Collapsible<S> { /* private fields */ }Expand description
A region shown while open is true, and the button that flips it.
It follows the WAI-ARIA disclosure pattern. The button has
aria-expanded bound to open and aria-controls pointing at the
region, so a screen reader announces it as expanded or collapsed, and
Enter and Space flip it. The region’s id is derived from the signal’s
path. The button and the region are separate elements, so the button can
sit in a heading or a toolbar away from the region.
Use Accordion for a stack of sections the visitor
opens without the server or other signals reading which one is open.
use hypersig::html::p;
use hypersig::{Page, Signals};
use hypersig_ui::{ButtonSize, ButtonVariant, Collapsible};
use serde::{Deserialize, Serialize};
#[derive(Signals, Serialize, Deserialize)]
struct Order {
details: bool,
}
let details = Collapsible::new(Order::details());
let html = Page::new("Order", Order { details: false })
.child(details.trigger(ButtonVariant::Ghost, ButtonSize::Sm).text("Details"))
.child(details.content().child(p().text("Shipped on Monday.")))
.render();
assert!(html.contains(r#"aria-expanded="false""#));
assert!(html.contains(r#"aria-controls="ui-details-content""#));Implementations§
Source§impl<S> Collapsible<S>
impl<S> Collapsible<S>
Sourcepub fn trigger(self, variant: ButtonVariant, size: ButtonSize) -> El<S>
pub fn trigger(self, variant: ButtonVariant, size: ButtonSize) -> El<S>
The button that shows and hides the region.
Trait Implementations§
Source§impl<S> Clone for Collapsible<S>
impl<S> Clone for Collapsible<S>
impl<S> Copy for Collapsible<S>
Auto Trait Implementations§
impl<S> Freeze for Collapsible<S>
impl<S> RefUnwindSafe for Collapsible<S>
impl<S> Send for Collapsible<S>
impl<S> Sync for Collapsible<S>
impl<S> Unpin for Collapsible<S>
impl<S> UnsafeUnpin for Collapsible<S>
impl<S> UnwindSafe for Collapsible<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