express.ui.insert_accordion_panel
express.ui.insert_accordion_panel(id,
panel_title,*panel_contents,
=MISSING,
panel_value=None,
panel_icon=None,
target='after',
position=None,
session )
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
, thetitle
will be used. panel_icon : TagChild = None
-
A
TagChild
which is positioned just before thetitle
. target : Optional[str] = None
-
The
value
of an existing panel to insert next to. position : Literal[‘after’, ‘before’] = 'after'
-
Should
panel
be 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
accordion
accordion_panel
update_accordion
Examples
#| 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)}",
)