Toast
Description
A stack of transient notifications appended to a toaster.
Usage
bc_toast(
title,
...,
description = NULL,
category = "info",
duration = NULL,
action = NULL,
cancel = NULL,
icon = NULL
)
bc_toaster(..., id = "toaster", align = "end")
bc_toast_trigger(
label,
...,
get,
toaster = "#toaster",
variant = "outline",
size = "default"
)
Arguments
| Argument | Description |
|---|---|
title |
String. The toast's title. |
... |
Content shown under the title before any description. |
description |
String. A description under the title. |
category |
String. One of info, success, warning or error. Sets styling and the default icon. |
duration |
Number. Milliseconds before the toast closes, or -1 to keep it open. Defaults to 3000, or 5000 for error toasts. |
action |
A list. Primary action with label and href or onclick. |
cancel |
A list. Secondary action with label and optional onclick. |
icon |
A tag. An icon before the text, replacing the category default. |
id |
String. The ID for the toaster. |
align |
String. Placement of the stack. One of start, center or end. |
label |
String. The trigger button's label. |
get |
String. URL of the fragment endpoint that returns bc_toast() markup. |
toaster |
String. CSS selector of the bc_toaster() to append into. |
variant |
String. Button variant, defaulting to outline. |
size |
String. Button size, defaulting to default. |
Value
A <div class="toast"> ready to append to a toaster.
A <div id="..."> of class toaster ready to hold toasts.
A <button> tag that fetches a server-rendered toast fragment.
Details
Append to a bc_toaster().
One per page, near the end of the body.
The endpoint returns bc_toast() markup, appended into the toaster.
Examples
bc_toast(
"Saved",
description = "Your changes are in place.",
category = "success",
cancel = list(label = "Dismiss")
)
Saved
Your changes are in place.
bc_toaster(
bc_toast("Upload failed", category = "error"),
align = "start"
)
Upload failed
bc_toast_trigger(
"Toast from backend (with HTMX)",
get = "/fragments/toast/success"
)