accordion
An accordion component for displaying collapsible content sections.
dx components add accordionDioxus components by the Dioxus team. Browse the catalog, copy the CLI command, and pull only what you need into your project. Thoughtfully designed with powerful accessibility features.
dx components listLive, interactive UI blocks composed from the primitives below. Use your keyboard to test the accessibility interactions.
Every primitive in the library, with live previews and a copy-paste install command for each one.
Basic Usage
Rounded
Loading
Error State
Large Size
| Su | Mo | Tu | We | Th | Fr | Sa |
|---|---|---|---|---|---|---|
Drag to reorder - top is highest priority
A simple item with title and description.
The table of contents tracks headings in this document and updates the active link while the scroll container moves through long-form content.
This preview keeps the navigation pinned in view so you can verify that the highlighted entry changes as each heading crosses the configured offset.
Render the table of contents beside the article and provide initial heading data so server rendering and the hydrated client show the same navigation structure.
The preview intentionally includes enough copy to force scrolling, making it easier to validate active heading transitions instead of relying on a static layout.
Use the selector to scope which headings participate and choose a scroll host when the document uses an internal panel instead of the browser window.
Indentation in the rendered list reflects heading depth, so a mix of h2, h3, and h4 entries is useful when checking hierarchy.
Offset tuning decides when a heading becomes active. In this demo the active item flips before the heading reaches the top edge, which keeps the label change readable during slower scrolling.
The primitive exposes initial data, selector configuration, a scroll host, and a reinitialize callback for dynamic documents that add or remove headings after first render.
The active state is still index-based in the core primitive. This preview only improves the surrounding layout and visual feedback.
Call reinitialize after heading content changes so the hook can rescan the document and keep the table of contents aligned with the rendered article.
Inactive items should stay readable but subdued. The active item needs stronger contrast, a clearer accent, and preserved indentation so the current heading stands out immediately.
Keeping the navigation sticky inside the scroll region lets the preview demonstrate both hierarchy and scroll-spy feedback in one compact example.
Consistent heading order and stable ids help keyboard users and assistive technology users move between the article and its generated navigation.
Scroll through this panel to watch the highlighted entry move from section to section. The demo now includes enough vertical space for the active item to change several times before the end of the document.
If you swap in your own content, keep a similar amount of spacing and section depth so the preview continues to exercise the component meaningfully.
Description here: sample text
Scroll this page to verify virtualized rendering with dynamic row heights.