Skip to contents

A speech bubble stays visible across mood changes and character swaps. Plain text is escaped; use htmltools::HTML() only for HTML you trust. A timed countdown pauses while the mascot is hidden or minimised, while the pointer is over the bubble, or while keyboard focus is anywhere inside the mascot, and resumes with the time left. Pressing Escape while focused inside the mascot closes the bubble. Closing a bubble removes it until the app supplies a new one. While the bubble shows, the mascot looks towards it: up when the bubble is above (inline and bottom corners), down when it is below (top corners).

Usage

mascot_bubble(text = NULL, ..., duration = 5, closable = TRUE)

Arguments

text

A non-empty string, optionally marked with htmltools::HTML(), or an htmltools tag or tag list. HTML-marked strings and tags are shown as HTML. Tags with dependencies or head content are not supported and give an error. NULL (the default) clears the bubble. With text = NULL, setting duration or closable yourself is an error; use mascot_bubble() without options to clear the bubble.

...

Must be empty. Forces the arguments after it to be named.

duration

How long the bubble stays visible: a number greater than zero, in seconds. Defaults to 5. Use Inf to keep the bubble until it is closed, replaced or cleared.

closable

A logical flag, defaulting to TRUE, to show a close button. FALSE hides the button; the Escape key still closes the bubble. NULL is not accepted.

Value

A mascot_bubble object. Its fields are internal; pass it on rather than reading them.

Details

Use the always visible status line for a short description of the current state. Use a bubble for a message about something that happened; it may time out. Use duration = Inf for a message the user must act on, such as an invalid form, because a timed message can vanish before it is read.

Bubble or menu? A bubble is a message the app shows; the server supplies or updates it with update_mascot(id, bubble = ...). For an action the visitor chooses, use mascot_popup_menu() with click = instead.

Examples

mascot_bubble("3 rows skipped")
#> mascot_bubble("3 rows skipped")
mascot_bubble("Ready", duration = Inf)
#> mascot_bubble("Ready", duration = Inf)
mascot_bubble(htmltools::HTML("<strong>Ready</strong>"))
#> mascot_bubble(htmltools::HTML("<strong>Ready</strong>"))
mascot_bubble()
#> mascot_bubble()