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

Update tooltip contents.


id: str

A character string that matches an existing tooltip id.

*args: TagChild = ()

Contents to the tooltip’s body.

show: Optional[bool] = None

Opens (True) or closes (False) the tooltip.

session: Optional[Session] = None

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


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

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

ui.input_action_button("btn_show", "Show tooltip", class_="mt-3 me-3")
ui.input_action_button("btn_close", "Close tooltip", class_="mt-3 me-3")
    "btn_update", "Update tooltip phrase (and show tooltip)", class_="mt-3 me-3"

with ui.tooltip(id="tooltip_id"):
        "A button w/ a tooltip",
        class_="btn-primary mt-5",
    "A message"

def _():
    ui.update_tooltip("tooltip_id", show=True)

def _():
    ui.update_tooltip("tooltip_id", show=False)

def _():
    content = "A " + " ".join(["NEW" for _ in range(input.btn_update())]) + " message"

    ui.update_tooltip("tooltip_id", content, show=True)

def _():
    ui.notification_show("Button clicked!", duration=3, type="message")