pub struct Accordion { /* private fields */ }Expand description
Accordion with collapsible sections
Implementations§
Source§impl Accordion
impl Accordion
Sourcepub fn new(id: impl Into<Id>, titles: Vec<impl Into<String>>) -> Self
pub fn new(id: impl Into<Id>, titles: Vec<impl Into<String>>) -> Self
Create a new accordion with the given ID and section titles
Sourcepub const fn allow_multiple(self, allow: bool) -> Self
pub const fn allow_multiple(self, allow: bool) -> Self
Allow multiple sections to be open simultaneously
Sourcepub fn show(
self,
ui: &mut Ui,
content_fn: impl FnMut(&mut Ui, usize),
) -> AccordionResponse
pub fn show( self, ui: &mut Ui, content_fn: impl FnMut(&mut Ui, usize), ) -> AccordionResponse
Show the accordion
Sourcepub fn show_ui(
self,
ui: &mut Ui,
count: usize,
render_trigger: impl FnMut(usize, &mut Ui, &ContentContext),
content_fn: impl FnMut(&mut Ui, usize),
) -> AccordionResponse
pub fn show_ui( self, ui: &mut Ui, count: usize, render_trigger: impl FnMut(usize, &mut Ui, &ContentContext), content_fn: impl FnMut(&mut Ui, usize), ) -> AccordionResponse
Show the accordion with custom trigger content for each section.
The trigger closure receives the section index, a &mut Ui, and a
ContentContext with state-dependent color, font size, and active state.
The content closure receives &mut Ui and the section index.
§Example
ⓘ
Accordion::new("my_accordion", Vec::<String>::new())
.allow_multiple(true)
.show_ui(ui, 2, |idx, ui, ctx| {
let titles = ["Section 1", "Section 2"];
ui.label(titles[idx]);
}, |ui, idx| {
ui.label(format!("Content for section {}", idx));
});Auto Trait Implementations§
impl Freeze for Accordion
impl RefUnwindSafe for Accordion
impl Send for Accordion
impl Sync for Accordion
impl Unpin for Accordion
impl UnsafeUnpin for Accordion
impl UnwindSafe for Accordion
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