Dialogs, prompts, and contextual feedback
A dialog asks for a decision or a short piece of information before an app continues a task. It is useful when the answer affects what happens next, such as confirming a deletion or naming a new item.
An action opens the dialog and awaits the result; the app can then continue or cancel its work.
button(res::str::delete()).action(move || {
day::task(async move {
let choice = Alert::new(res::str::delete_title())
.message(res::str::delete_body())
.destructive(res::str::delete(), Choice::Delete) // a button carrying a payload
.cancel(res::str::cancel()) // dismissal → None
.present()
.await; // -> Option<Choice>
if choice == Some(Choice::Delete) {
store.delete(id);
}
});
});
Use day::task to await a dialog from a synchronous action.
The UI snippets use generated res::str accessors from an app’s Fluent catalog; see the
example messages and catalog setup.
Tooltips
Attach .tooltip(...)
to a piece to explain a control on hover or long press. It accepts the same text sources as a
label, including generated localized messages and reactive closures.
Changing the source updates the mounted control. Empty text clears the help. Give an icon-only
control an accessible name so its purpose is also available
to a screen reader. On touch toolkits that emulate help with a long press, a context menu or
an explicit long-press action on the control takes priority.
Apps migrating from the tooltip tweak can remove its dependency and trait import. The modifier is available through the Day prelude.
button(res::str::feedback_trigger())
.tooltip(res::str::feedback_hint())
Popovers
Attach .popover(open, content)
to the piece the panel should point to. Its boolean binding controls presentation. The trigger
can use its normal button action, so keyboard and accessibility activation open the same panel.
Each opening builds the content in a fresh scope. Put state that should survive dismissal in
the enclosing page. The panel can contain ordinary Day labels, inputs, and actions.
let open = Signal::new(false);
let enabled = Signal::new(true);
button(res::str::feedback_trigger())
.action(move || open.set(true))
.tooltip(res::str::feedback_hint())
.popover(open, move || {
column((
label(res::str::feedback_autosave()),
toggle(enabled).a11y(|a| a.label(res::str::feedback_autosave())),
button(res::str::feedback_done()).action(move || open.set(false)),
)).spacing(Space::S).padding(Space::M)
})
The toolkit places the panel relative to the trigger. Day measures its content at opening and again when the
content or window changes, with a maximum proposed width of 320 points and a 12-point window
margin. Resizing an open panel preserves its controls and their state. Use a scroll view for
content that can exceed the available height. A click or tap outside dismisses the panel and
writes false to the binding. Setting the binding to false closes it programmatically.
Removing the trigger releases its panel and the content’s handlers.
Toasts
Call toast(...) from a UI action to
show a short status message in the current window. The text resolves when called. The toolkit
hides it after a brief interval and the user can keep working. An empty message has no effect.
Use a popover for an action that needs a button and an alert
for a decision that must finish before work continues.
button(res::str::feedback_done()).action(|| toast(res::str::feedback_enabled()))
Toolkit behavior
| Toolkit | Tooltip | Popover | Toast |
|---|---|---|---|
| AppKit | View tooltip | Transient NSPopover | Visual effect view over the window |
| UIKit | Pointer tooltip and long-press help | Popover presentation controller | Label above the bottom safe area, tab bar, and docked keyboard |
| GTK | Widget tooltip | GtkPopover | libadwaita toast overlay |
| Qt | Widget tooltip | Widget with the popup window flag | Timed label in the window |
| Material | AndroidX tooltip, including older Android versions | Focusable popup window | In-app Material Snackbar |
| WinUI and system XAML | Tooltip service | Flyout | Timed XAML popup |
| ArkUI | Long-press help | PromptAction popup | PromptAction toast |
| DOM | Browser title and touch help | HTML popover with a positioned fallback | Timed status overlay |
In Day Showcase, open Navigation & chrome → Tooltips, popovers & toasts. Each example has its own text length selector. Hover over Draft, or touch and hold it, to read the tooltip. Choose Long, enable Narrow panel, and select Open popover to see how the paragraph wraps. Close the panel, turn off Narrow panel, and reopen it to compare. Select Show toast for a temporary save message.
Alerts, confirmations, and prompts
alert(res::str::saved()).present(); // fire-and-forget notice (1 button)
let ok: bool = confirm(res::str::quit()).await;
let name: Option<String> = prompt(res::str::name()).await; // -> Option<String>
// full builder: buttons carry a typed payload; `.cancel()` and dismissal → None
let picked: Option<Flavor> = Alert::new(res::str::pick())
.button(res::str::vanilla(), Flavor::Vanilla)
.button(res::str::pistachio(), Flavor::Pistachio)
.sheet() // bottom action sheet on mobile
.cancel(res::str::cancel())
.present().await;
Every text field is an IntoText, so titles and buttons accept generated res::str messages.
Toolkit implementations
Platform guidance: Apple: alerts; Android: dialogs; Windows: dialogs.
| Toolkit | Dialog / sheet | Prompt |
|---|---|---|
| appkit | NSAlert + beginSheetModalForWindow: (async) | NSAlert with an NSTextField accessory |
| uikit | UIAlertController (.alert / .actionSheet) on the root VC | UIAlertController + addTextField |
| gtk | AdwAlertDialog (libadwaita 1.5; response signal) | AdwAlertDialog with a GtkEntry extra-child |
| qt | QMessageBox.open() + finished (shim) | QInputDialog.getText (shim) |
| android | MaterialAlertDialogBuilder (buttons / setItems for sheets) | M3 dialog + TextInputLayout |
| arkui | ArkUI PromptAction.openCustomDialog modal with themed native Text / Button content; sheets align to the bottom | Same modal host with native TextInput, initial value, placeholder and IME submit |
| mock | records the spec; resolved programmatically | same |
| WinUI | ContentDialog | ContentDialog + TextBox |
The main loop keeps running while a dialog is open.
ArkUI
Dialogs use the primary window. Alerts support multiple buttons, destructive choices,
scrolling content, and Back or outside dismissal. Action-sheet choices are vertical.
A prompt returns Some("") for an accepted empty value and None for cancellation.
The answer is delivered after the native dialog closes, so the continuation can open another.
Lifetime
Dialogs attach to the active window where supported. On ArkUI they use the primary window. Do not assume that disposing the initiating UI subtree cancels an outstanding dialog task. Check the app state again before applying its answer. See Async work for task ownership and cancellation.
Use file pickers for open/save operations and windows for additional app windows.