ui.accordion_panel

ui.accordion_panel(title, *args, value=MISSING, icon=None, **kwargs)

Single accordion panel.

Parameters

title : TagChild

A title to appear in the accordion_panel’s header.

*args : TagChild | TagAttrs = ()

Contents to the accordion panel body. Or tag attributes that are supplied to the returned Tag object.

value : Optional[str] | MISSING_TYPE = MISSING

A character string that uniquely identifies this panel. If MISSING, the title will be used.

icon : Optional[TagChild] = None

A Tag which is positioned just before the title.

****kwargs** : TagAttrValue = {}

Tag attributes to the accordion-body div Tag.

Returns

: AccordionPanel

AccordionPanel object.

References

Bootstrap Accordion

See Also

Examples

#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400

## file: app.py
from shiny import App, Inputs, Outputs, Session, reactive, render, ui

items = [
    ui.accordion_panel(f"Section {letter}", f"Some narrative for section {letter}")
    for letter in "ABCDE"
]

app_ui = ui.page_fluid(
    # Provide an id to create a shiny input binding
    ui.accordion(*items, id="acc"),
    ui.h4("Accordion:"),
    ui.output_text_verbatim("acc_val", placeholder=True),
)


def server(input: Inputs, output: Outputs, session: Session):
    @reactive.effect
    def _():
        print(input.acc())

    @render.text
    def acc_val():
        return "input.acc(): " + str(input.acc())


app = App(app_ui, server)