ui.show_offcanvas

ui.show_offcanvas(offcanvas, *, session=None)

Show an offcanvas panel.

Programmatically displays an offcanvas panel in the user's session by inserting its HTML into the page.

Parameters

offcanvas : Offcanvas

An Offcanvas object created by offcanvas.

session : Optional[Session] = None

The Session to show the panel in. If not provided, the session is inferred via get_current_session.

Returns

: str

The local (pre-namespace) ID of the displayed panel.

Note

If a panel with the same id is already present on the page, show_offcanvas() simply reveals it — the content is not re-rendered. To update an id’d panel’s content, update the reactive outputs it contains rather than calling show_offcanvas() again.

See Also

Examples

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

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

app_ui = ui.page_fluid(
    ui.input_action_button("show_btn", "Show panel"),
)


def server(input: Inputs, output: Outputs, session: Session):
    @reactive.effect
    @reactive.event(input.show_btn)
    def _():
        ui.show_offcanvas(
            ui.offcanvas(
                ui.p("This panel was inserted dynamically by the server."),
                title="Server Panel",
                placement="left",
            )
        )


app = App(app_ui, server=server)