express.ui.update_sidebar(id, *, show=None, session=None)

Update a sidebar's visibility.

Set a sidebar state during an active Shiny user session.


id: str

The id of the sidebar to toggle.

show: Optional[bool] = None

The desired visible state of the sidebar, where True opens the sidebar and False closes the sidebar (if not already in that state).

session: Optional[Session] = None

A Shiny session object (the default should almost always be used).

See Also


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

## file:
from shiny import reactive
from import input, render, ui

with ui.sidebar(id="sidebar"):
    "Sidebar content"

ui.input_action_button("open_sidebar", label="Open sidebar", class_="me-3")
ui.input_action_button("close_sidebar", label="Close sidebar", class_="me-3")

def state():
    return f"input.sidebar(): {input.sidebar()}"

def _():
    ui.update_sidebar("sidebar", show=True)

def _():
    ui.update_sidebar("sidebar", show=False)