NIB / DOCUMENTATION
Accordion — NibComponents
Coordinate expandable sections, then decide whether several can remain open.
Open interactive viewOpen a section and observe coordination
Tap a header in the preview. Its content becomes available, and the callback records the section index and whether it opened. Open a different section: the default single-open policy closes the previous one. Switch Allow multiple sections on to keep several answers visible.
Each NibAccordionItem has a Widget title and content, optional leading widget, and an enabled flag. Use real headings and concise content rather than placing another scroll view inside each answer. The disabled second section demonstrates unavailable interaction without removing the section from the page.
Choose internal or external expansion state
The widget creates a controller if controller is omitted. This demo supplies one so Open first and Close all can operate from outside a header. NibAccordionController.openIndices is an unmodifiable snapshot; use open, close, toggle, openAll, or closeAll to change it. openAll is ignored in single-open mode.
Create the external controller once and dispose it when the owning screen leaves. allowMultipleOpen is synchronized with the controller. defaultOpenIndex seeds the internally created controller; it is not a command to reopen a section on every build.
Keep expansion useful without motion
animated defaults to false. Enable it to animate the height reveal and chevron response; transition configures the requested timing. An expanded section must remain readable with animation off. The preview preserves open state while appearance controls change.
Try opening the second section and then disabling it. Disabled controls should not become a workaround for hiding important information. If your application needs to close a section when permission changes, update the controller explicitly.
Compose readable sections
The accordion grows with its content. Put the whole article in the screen’s scroll container; do not give it an arbitrary short height that clips revealed text. Test long titles and large text scaling at narrow widths.
The demo is local UI state. Expanding a section does not fetch content or change routes. Add asynchronous loading and access checks in the host if a real section needs them.