accordion
probo.styles.frameworks.bs5.components.accordion
BS5Accordion
Bases: BS5Component
A high-level component for generating Bootstrap 5 Accordions.
This class automates the creation of multi-item collapsible containers. It manages the generation of unique IDs for parent-child relationships, ensuring that clicking a header correctly toggles the corresponding body without affecting other items.
Attributes:
| Name | Type | Description |
|---|---|---|
items |
list
|
A collection of dictionaries containing the header and body data for each accordion segment. |
__init__(*accordion_items, variant='base', render_constraints=None, **attrs)
Initializes the accordion container with state and variants.
add_accordion_item(accordion_header, header_id, accordion_body, body_id)
Registers a new item to be rendered within the accordion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
accordion_header
|
str
|
The text or HTML to display in the clickable header button. |
required |
header_id
|
str
|
The unique HTML ID for the header element. |
required |
accordion_body
|
str
|
The HTML content to display when expanded. |
required |
body_id
|
str
|
The unique HTML ID for the collapsible body container. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
self |
Self
|
Enables fluent method chaining. |
before_render(*args, **kwargs)
Integrates all registered accordion items before final string conversion.