ConfirmDialog

ConfirmDialog

HkConfirmDialog is the short confirmation: a message, a primary verb and a dismiss verb, in the compact 24rem frame rather than a half-empty modal. It is a thin composition over HkModal — the frame, the dim backdrop, the focus trap, the Escape and overlay paths all belong to the modal — and its own contract is about what a decision means: which path the chrome takes, and which of the two emits the caller gets.

  • Reach for it when the answer is binary and the sentence is short: "Delete these 3 rules?" — a verb and a dismiss.
  • Reach for Modal when the surface has a form, several fields, or a body the user must read before acting; for a longer decision with a checkbox or a typed confirmation, the modal is also the right host.
  • For a confirmation raised imperatively from a call site that does not render components, use MessageBox, the command-style sibling that hosts the same pair of buttons.

Import

tsx
1
import { HkConfirmDialog } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // ConfirmDialog, ConfirmVariant
use hikari_components::prelude::*; // ConfirmDialogProps, rsx!, VNode, EventHandler, MouseEvent

The Rust form is a plain function, ConfirmDialog(ConfirmDialogProps { … }). Inside rsx! every prop may be omitted, and closed renders nothing. Note the open flag's name on the Vue side: this component uses open / update:open, not modelValue.

A decision, two buttons, and one dismissal path

The pair lives in the modal's footer band: the primary action first, the dismiss second — the message-box order shared with the rest of the family. The row is a pure visual row, so it mirrors under dir="rtl" without any reordering logic. The message sits above, in the body, vertically centred against a 4rem floor so a one-line confirmation does not look cramped.

confirmVariant picks the confirm ink: danger (the default — a confirmation is usually about something that cannot be undone) or primary. The dismiss button is always secondary. Both labels fall back to the localized hikari::confirmDialog.confirm ("Confirm") and hikari::confirmDialog.cancel ("Cancel") when the prop is empty, so a page never ships an untranslated blank button.

loading locks the decision: the ✕ disappears (the modal is rendered with closable: false), the dismiss button is disabled, and the confirm button shows its busy state. That is the shape a caller wants while it awaits the action behind the confirmation — nothing can be answered twice.

This example is rendered in the browser and needs JavaScript.

Both cards paint the same 24rem frame with its title bar and the footer pair. In a snapshot neither button does anything; wire the three emits on the Vue side and the two on_* handlers on the Rust side.

What the chrome does — and why it is never a no-op

open is caller-owned in both forms, so a dismissal is only a request: the component tells the caller to close, and keeps rendering until the caller writes the flag back. The important part is which channel a dismissal travels on.

[D] Vue and Rust disagree on what the window chrome means, and the Vue behaviour is the one the product needs:

  • Vue — onModalUpdate inspects the modal's request. true is relayed as update:open; false goes through onCancel(), which emits cancel and update:open(false). So the ✕, an overlay press and Escape are all a cancel: a caller awaiting the answer settles, and the window comes down. This is deliberate — the earlier behaviour relayed the close as update:open alone, which left the dialog on screen and the caller's promise pending until unmount (2026-09-11 incident).
  • Rust — the chrome's dismissal is routed internally to the modal's on_close, which the mirror wires to the same handler as on_cancel. So on_cancel fires, and on_open_change does not get false. ConfirmDialogProps exposes no on_close of its own; a host that listens only to on_open_change sees a ✕ that looks like a no-op until it also handles on_cancel.

loading is mirrored honestly on both sides: closable: false on the modal, a disabled dismiss button, a busy confirm button. In Vue the ✕ is gone in that state, so the chrome path is closed off entirely.

This example is rendered in the browser and needs JavaScript.

The busy frame: no ✕ in the title bar (the modal is rendered non-closable), a dimmed dismiss button and a spinning confirm. Both cards are the same state, and neither mutates it — loading is a prop, not something the component ends on its own.

Wider than it looks: what is not forwarded

The wrapper renders a fixed subset of the modal's surface, and the subset is the whole contract: title, closable and the width preset 24rem, plus the message and the pair. Everything else on HkModal is out of reach — and the two implementations also stop agreeing about where the pair goes:

  • [D] where the pair renders. Vue hosts the confirm pair in HkModal's footer slot (a 2026-11-05 move, the same slot MessageBox uses), so the buttons sit in the bordered footer band. The Rust mirror passes the message *and* the hk-confirm-dialog-actions row as the Modal's body child, so the pair renders inside the body, above the frame's bottom padding and with no divider strip. The classes are identical (hk-confirm-dialog, hk-confirm-dialog-message, hk-confirm-dialog-actions, hk-confirm-dialog-btn) and the shared sheet sizes the row either way; the band is what differs.
  • Button renderer. Vue uses HButton (size="md"); the Rust mirror uses the crate's own Button at ButtonSize::Md. Both emit the same class contract (.hk-btn + .hk-btn-<variant> + .hk-btn-md), so the row looks the same; treat it as the same button, not as a second feature.
  • Neither form exposes width, padding, surfaceTitle or any of the modal's runtime props: those decisions are closed. If the confirmation needs one of them, it is not a confirmation any more — build it with HkModal.
  • title is optional, and leaving it out has a cost. The modal's header band renders when there is a title, a header slot or closable, so the header always exists here — a titleless confirm renders a bar holding an empty h2 and the ✕, and its accessible name is empty too. Pass a title for anything a screen reader will meet.
This example is rendered in the browser and needs JavaScript.

A message-only confirmation with the default label pair: "Confirm" and "Cancel" come from the i18n bundle on both sides, so the same fence renders localized buttons on any page. The rendered Rust markup for this fence is aria-label="" on the frame, an empty <h2 class="hk-modal-title"></h2> in the header, and the pair inside the body — which is exactly why this shape needs a title before it ships.

API

Vue

Props

NameTypeDefaultRequired
openBoolean—✓
titleString""—
messageString""—
confirmLabelString""—
confirmVariant<code>String as () => "primary" | "danger"</code>"danger"—
cancelLabelString""—
loadingBooleanfalse—

Emits

EventPayload
confirm—
cancel—
update:openboolean

Rust

Props — ConfirmDialog

PropTypeDefaultDescription
openboolfalseControlled open state (Vue: open, required).
titleString""—
messageString""—
confirm_labelString""Confirm button label; falls back to the localized default.
confirm_variantConfirmVariantConfirmVariant::DangerConfirm ink: danger (default) or primary.
cancel_labelString""Cancel button label; falls back to the localized default.
loadingboolfalseBusy state: disables the cancel path and the ✕.
on_confirmOption<EventHandler<MouseEvent>>NoneFired when the user confirms (before the close request).
on_cancelOption<EventHandler<MouseEvent>>NoneFired when the user cancels — including ✕ / overlay / Esc dismissals, so callers can settle their pending decision.
on_open_changeOption<EventHandler<bool>>NoneFired with the desired open state after either path.

Accessibility

  • The surface is the modal's: role="dialog", aria-modal="true", a trapped Tab cycle and focus restored to the opener on close. The confirm frame is 24rem wide; at touch widths the two buttons grow to a 44px minimum target and share the row equally.
  • The accessible name comes from the modal's aria-label, which is title. A confirmation without a title is an unnamed dialog, and the message text is content, not a name — always pass title.
  • The primary verb comes first in the DOM, matching the message-box family. confirmVariant="danger" is the only signal the component carries on its own — and it is colour only; the wording ("Delete" rather than "OK") is the caller's job, and it is what a screen reader actually says.
  • The default labels are localized through hikari::confirmDialog.confirm / hikari::confirmDialog.cancel, so a confirmation that passes no labels is still announced in the page's language; a custom label replaces that fallback silently, so translate it on your side.
  • [D] The Rust frame writes aria-label unconditionally, so an untitled confirmation renders aria-label="" rather than omitting the attribute as Vue does. Either way the dialog is unnamed — the difference is only whether the attribute is present.
  • While loading, the dismiss button is disabled and the ✕ is not rendered at all — so the dialog is a genuine dead end until the caller clears the flag. Make sure the awaited work always settles the state (loading: false on failure too, or close the dialog), otherwise the user is stuck with an Escape key that no longer closes.
  • [D] The Rust chrome reaches on_cancel for a keyboard or overlay dismissal but never calls on_open_change(false), so a host that treats on_open_change as the single dismissal channel will not see it close. Handle on_cancel for dismissal; a host that needs the open flag flipped as well cannot get that from this component — build the dialog from Modal itself if the flag must be authoritative.

Related components

  • Modal — the frame this component is built on, and the host for longer decisions.
  • MessageBox — the imperative sibling that hosts the same footer pair.
  • AdaptiveDialog — a dialog that adapts its shell, when the flow differs on phones.
  • Drawer — an edge-docked surface instead of a centred interruption.
  • ProgressDialog — the non-closable busy window, when the answer is "wait" rather than "choose".