Skip to content

Cratis Components dialogs: choose an interaction

Cratis Components dialogs let you ask for a decision or collect values while the caller controls what happens next. Use a custom Dialog when the caller needs a typed result, ConfirmationDialog for a prompt, or BusyIndicatorDialog while an operation completes. Import them from @cratis/components/Dialogs:

import { BusyIndicatorDialog, ConfirmationDialog, Dialog } from '@cratis/components/Dialogs';
You want to… Use Reference
Ask the user to confirm or cancel an action and await the button they chose ConfirmationDialog, triggered with useConfirmationDialog ConfirmationDialog
Block the screen with a spinner while a long-running operation completes BusyIndicatorDialog, shown with useBusyIndicator BusyIndicatorDialog
Show your own content, collect values, and return a typed result to the caller Dialog with useDialog / useDialogContext Dialog
Show a detail pane against the side of the viewport Dialog with placement='start' or 'end' Dialog placement

Register ConfirmationDialog and BusyIndicatorDialog once with Cratis Arc’s DialogComponents, then open them through the hooks from @cratis/arc.react/dialogs. These built-in dialogs display the title and message supplied in the request; the confirmation request also selects the buttons. Choose Dialog when you need your own content. The Getting started setup supplies the runtime and providers; CratisComponentsProvider alone does not register the Arc dialog host.

For a custom dialog, render the wrapper returned by useDialog and await its show function. The dialog calls closeDialog(result, value?) through useDialogContext; the caller receives [DialogResult, value?]. Check the result and optional value before using them. DialogResult.Cancelled means the interaction ended without confirmation, not that an application operation succeeded or failed. Follow the typed Dialog example to wire both sides.

When confirming should validate and execute a generated Arc command, choose CommandDialog instead. It binds the command and manages validation and busy state during submission. A successful command normally closes the dialog; a failed command leaves it open. The form recipe walks through that command flow. A plain Dialog only reports the user’s choice unless you supply the operation yourself.

Give the dialog a meaningful title and labels that make sense without icons. For a destructive choice, use DialogInitialFocus.Cancel to focus Cancel or No rather than confirm. Use Content to focus the title without selecting an action. The initial-focus contract explains the fallbacks for custom footers.

With predefined buttons, the header close button, Escape, and a backdrop click report DialogResult.Cancelled. Custom footers and dialogs without a footer disable those dismissal paths by default; configure them explicitly and provide a way out. See dismissal controls. Outside useDialog, your callbacks must update visible themselves.

Before relying on the interaction, check its keyboard path in your application: open it, move through the controls, cancel or confirm, and check where focus returns. Repeat for each dismissal path you enable. This checks the dialog flow, not application-wide accessibility conformance.

When not to use a dialog from this subpath

Section titled “When not to use a dialog from this subpath”

For the wider decision across subpaths, see Choosing a component.