express.ui.insert_accordion_panel
express.ui.insert_accordion_panel(
id,
panel_title,
*panel_contents,
panel_value=MISSING,
panel_icon=None,
target=None,
position='after',
session=None,
)Insert an accordion panel into an existing accordion.
Parameters
id : str-
A string that matches an existing
accordion’sid. panel_title : str-
The title to appear in the panel header.
panel_contents : Union[TagChild, TagAttrs] = ()-
UI elements for the panel’s body. Can also be a dict of tag attributes for the body’s HTML container.
panel_value : Union[str, MISSING_TYPE, None] = MISSING-
A character string that uniquely identifies this panel. If
MISSING, thetitlewill be used. panel_icon : TagChild = None-
A
TagChildwhich is positioned just before thetitle. target : Optional[str] = None-
The
valueof an existing panel to insert next to. position : Literal[‘after’, ‘before’] = 'after'-
Should
panelbe added before or after the target? Whentarget=None,"after"will append after the last panel and"before"will prepend before the first panel. session : Optional[Session] = None-
A Shiny session object (the default should almost always be used).
References
See Also
accordionaccordion_panelupdate_accordion
Examples
#| '!! shinylive warning !!': |
#| shinylive does not work in self-contained HTML documents.
#| Please set `embed-resources: false` in your metadata.
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
import random
from shiny import reactive
from shiny.express import input, ui
ui.input_action_button("add_panel", "Add random panel", class_="mt-3 mb-3")
with ui.accordion(id="acc", multiple=True):
for letter in "ABCDE":
with ui.accordion_panel(f"Section {letter}"):
f"Some narrative for section {letter}"
@reactive.effect
@reactive.event(input.add_panel)
def _():
ui.insert_accordion_panel(
"acc",
f"Section {random.randint(0, 10000)}",
f"Some narrative for section {random.randint(0, 10000)}",
)