ui.update_popover
ui.update_popover(id, *args, title=None, show=None, session=None)
Update the contents or title of a popover.
Parameters
id: str
-
The id of the popover DOM element to update.
*args: TagChild = ()
-
The new contents of the popover.
title: Optional[TagChild] = None
-
The new title of the popover.
show: Optional[bool] = None
-
Opens (
True
) or closes (False
) the popover. session: Optional[
Session
] = None-
A Shiny session object (the default should almost always be used).
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("btn_show", "Show popover", class_="mt-3 me-3"),
ui.input_action_button("btn_close", "Close popover", class_="mt-3 me-3"),
ui.br(),
ui.br(),
ui.popover(
ui.input_action_button("btn_w_popover", "A button w/ a popover", class_="mt-3"),
"A message",
id="popover_id",
),
)
def server(input: Inputs, output: Outputs, session: Session):
@reactive.effect
@reactive.event(input.btn_show)
def _():
ui.update_popover("popover_id", show=True)
@reactive.effect
@reactive.event(input.btn_close)
def _():
ui.update_popover("popover_id", show=False)
@reactive.effect
@reactive.event(input.btn_w_popover)
def _():
ui.notification_show("Button clicked!", duration=3, type="message")
app = App(app_ui, server=server)