@@ -31,7 +31,7 @@ class ToastPayload(RenderedDeps):
3131
3232
3333class Toast :
34- """Internal class representing a toast notification."""
34+ """A toast notification (internal class) ."""
3535
3636 def __init__ (
3737 self ,
@@ -63,6 +63,7 @@ def _normalize_type(self, type: Optional[str]) -> Optional[str]:
6363 return type
6464
6565 def as_payload (self , session : Session ) -> ToastPayload | None :
66+ """Create the Shiny custom message payload for this toast."""
6667 # Return None if toast has no content
6768 if not self .body and self .header is None :
6869 return None
@@ -211,32 +212,34 @@ def toast(
211212 Create a toast notification object.
212213
213214 Toast notifications are temporary, non-intrusive messages that appear on screen to
214- provide feedback to users. They support multiple semantic types, flexible positioning,
215- auto-hide with progress bars, and optional headers with icons.
215+ provide feedback to users. They support multiple semantic types, flexible
216+ positioning, auto-hide with progress bars, and optional headers with icons.
216217
217218 Parameters
218219 ----------
219220 *args
220221 Body content (HTML elements or strings). Named arguments become HTML attributes.
221222 header
222- Optional header content. Can be a string (auto-converted to header), a
223- ToastHeader object from :func:`~shiny.ui.toast_header`, or any TagChild .
223+ Optional header content. Can be a string (auto-converted to header), or a
224+ toast header object from :func:`~shiny.ui.toast_header`.
224225 icon
225- Optional icon element to display in the toast body (e.g., from ui.tags.i()
226- or icon library). The icon appears in the body regardless of whether a header
227- is present.
226+ Optional icon element to display in the toast body.
228227 id
229228 Optional unique identifier. Auto-generated if None.
230229 type
231- Semantic type for styling. Options are "primary", "secondary", "success",
232- "info", "warning", "danger", "error" (alias for "danger"), "light", "dark".
230+ Semantic type for styling. Options are `"primary"`, `"secondary"`, `"success"`,
231+ `"info"`, `"warning"`, `"danger"`, `"error"` (alias for `"danger"`), `"light"`,
232+ `"dark"`.
233233 duration_s
234- Auto-hide duration in seconds. Use None or 0 to disable auto-hide.
234+ Auto-hide duration in seconds. Use ` None` or `0` to disable auto-hide.
235235 position
236- Screen position. Accepts "top-left", "top left", ["top", "left"], etc.
236+ Screen position. Accepts ` "top-left"`, ` "top left"`, ` ["top", "left"]` , etc.
237237 Valid positions are combinations of (top/middle/bottom) × (left/center/right).
238238 closable
239- Whether to show close button.
239+ Whether to add a close button, allowing the user to close the toast. Defaults to
240+ `True`. When `False` and auto-hide is disabled, the toast cannot be dismissed by
241+ the user; use only when appropriate and be certain to close the toast
242+ programmatically with :func:`~shiny.ui.hide_toast`.
240243 **kwargs
241244 Additional HTML attributes for the toast element.
242245
@@ -355,7 +358,7 @@ def toast_header(
355358 *args
356359 Additional content to append to title.
357360 icon
358- Optional icon element (e.g., from ui.tags.i() or icon library) .
361+ Optional icon element.
359362 status
360363 Optional status text (appears muted/right-aligned, e.g., "just now").
361364 **kwargs
0 commit comments