express.ui.notification_show(ui, *, action=None, duration=5, close_button=True, id=None, type='default', session=None)

Show a notification to the user.

A notification is a message that appears near the bottom corner of the app. Notifications normally disappear after a short period of time, and should multiple notifications appear together, they will stack on top of one another.


ui: TagChild

Contents of the notification message.

action: Optional[TagChild] = None

Message content that represents an action. For example, this could be a link that the user can click on. This is separate from ui so customized layouts can handle the main notification content separately from the action content.

duration: Optional[int | float] = 5

Number of seconds to display the message before it disappears. Use None to prevent the message from disappearing automatically. The user will need to click the corner of the notification to close it.

close_button: bool = True

If True, display a button which will make the notification disappear when clicked. If False do not display.

id: Optional[str] = None

An optional unique identifier for the notification. If supplied, any existing notification with the same id will be replaced with this one (otherwise, a new notification is created).

type: Literal[‘default’, ‘message’, ‘warning’, ‘error’] = ‘default’

A string which controls the color of the notification. This should be one of “default” (gray), “message” (blue), “warning” (yellow), or “error” (red).

session: Optional[Session] = None

The Session in which the notification should appear. If not provided, the session is inferred via get_current_session.


Type Description
str The notification’s id.

See Also


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

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

ui.input_action_button("show", "Show")
ui.input_action_button("remove", "Remove")

ids: list[str] = []
n: int = 0

def _():
    global ids
    global n
    # Save the ID for removal later
    id = ui.notification_show("Message " + str(n), duration=None)
    n += 1

def _():
    global ids
    if ids: