Skip to content

Accordion

Source code for examples/outputs/accordion.py

Tip: paste this code into an empty cell, and the marimo editor will create cells for you

import marimo

__generated_with = "0.12.9"
app = marimo.App()


@app.cell
def _():
    import marimo as mo
    return (mo,)


@app.cell
def _(mo):
    mo.accordion(
        {
            "Door 1": mo.md("Nothing!"),
            "Door 2": mo.md("Nothing!"),
            "Door 3": mo.md(
                "![goat](https://images.unsplash.com/photo-1524024973431-2ad916746881)"
            ),
        }
    )
    return


if __name__ == "__main__":
    app.run()

marimo.accordion

accordion(
    items: dict[str, object],
    multiple: bool = False,
    lazy: bool = False,
) -> Html

Accordion of one or more items.

PARAMETER DESCRIPTION
items

a dictionary of item names to item content; strings are interpreted as markdown

TYPE: dict[str, object]

multiple

whether to allow multiple items to be open simultaneously

TYPE: bool DEFAULT: False

lazy

a boolean, whether to lazily load the accordion content. This is a convenience that wraps each accordion in a mo.lazy component.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
Html

An Html object.

Example
mo.accordion(
    {"Tip": "Use accordions to let users reveal and hide content."}
)

Accordion content can be lazily loaded:

mo.accordion({"View total": expensive_item}, lazy=True)

where expensive_item is the item to render, or a callable that returns the item to render.