Skip to content

Confirm

Last updated 11 Nov 2026

NbConfirm asks one question, in one shape, everywhere: is this the thing you meant to destroy?

Accessibility ​

  • The dialog is aria-modal="true" (from NbModal). NbConfirm sets role="alertdialog" for the danger tone and leaves role="dialog" for neutral: a destructive confirm interrupts rather than being navigated to, and alertdialog is what makes a screen reader read the description on entry instead of waiting to be asked.
  • aria-labelledby points at the title and aria-describedby at the description (the message, the slot content and the subject strip), so entering announces the action and the record rather than the word "dialog". A title-only confirm sets no aria-describedby at all rather than naming an empty element.
  • Initial focus follows Carbon, with its exception for destructive dialogs kept as the rule. A danger confirm (the default) opens on Cancel, never on the confirm button and never on the type-to-confirm field. A neutral confirm is a transactional dialog: it opens on the type-to-confirm field when there is one, and on the confirm button otherwise.
  • The tab order is confirm, then Cancel, then the close button. Cancel is drawn on the left and confirm on the right. The footer's NbButtonSet writes the primary first so Tab from the body reaches it first, as in every Carbon dialog.
  • Tab and Shift+Tab cycle within the dialog. Focus that leaves it any other way (a click on the page behind the scrim, a focus() call from application code, a control being disabled under the caret) is recovered on focusout, not only on a keystroke.
  • While busy the dialog has no focusable control at all, because cancel, confirm, the gate field and the close button are disabled together. A browser does not hold focus on a control it has just disabled: it drops it on <body>, outside the dialog, where Esc does nothing and a screen reader is reading the page behind the scrim. NbModal carries tabindex="-1" on the dialog box for exactly this, and NbConfirm moves focus there as the pending state begins, and again if anything knocks it out. When the work comes back with a failure, focus moves to the failure itself, which is the sentence the user has to read before deciding whether to retry.
  • A popup that one of the dialog's own controls teleports to <body> (NbSelect's list, NbMenu, NbDatePicker's calendar, NbUserMenu's panel) is treated as part of the dialog, so opening one inside the body slot does not get focus yanked back out of it. Anything else opts in three ways: a data-nb-confirm-floating attribute on the teleported root, the floatingSelectors prop for one dialog, or registerConfirmFloatingSelector('.their-dropdown') once at application start for a third-party popup whose markup you do not own.
  • The tab cycle knows about more than buttons and inputs, because the body slot takes arbitrary content: iframe, [contenteditable], audio[controls], video[controls], area[href], summary and anything with a positive tabindex are all stops, while [tabindex="-1"], [hidden] and [aria-hidden="true"] are not. A preview of the record being deleted is often one of those, and a cycle that does not know about it breaks at the dialog edge.
  • A drag that starts inside the dialog (selecting the record's name to copy it) and releases over the scrim does not cancel. By the DOM's reckoning that is a click on the overlay; by the user's it is not a click outside anything.
  • Esc is answered here and stopped here, in the capture phase, but only when this dialog is the last aria-modal surface in the document, which for teleported overlays is the one painted on top. An application NbModal underneath does not also close, and neither does an older NbConfirm when two are open at once. While busy, nothing closes at all.
  • Esc pressed inside one of those teleported popups closes the popup, not the dialog: the floating-menu test runs before the Esc branch, not after it.
  • Focus returns to the element that was focused before the dialog opened, so a delete launched from a row menu returns you to that row. It returns on dismissConfirms() too, which destroys the dialog rather than closing it.
  • The pending state sets aria-busy="true" on the dialog and renders busyLabel in a role="status" region, because a button that has quietly become disabled announces nothing. That region, the finished beat and the failure all sit outside the element aria-describedby points at. An alertdialog announces its description on entry, and text inserted into that same subtree a moment later is at the mercy of how a given screen reader merges the two; kept separate, each of these is an ordinary polite update to a region that was empty, which is the case assistive technology handles the same way everywhere. Which of them is spoken, and how promptly, is still the user's screen reader's decision and not something this library can assert.
  • Failures render in NbMessage with variant="error", and focus moves to the failure, so it is read even if the live region is not.
  • The confirm button is disabled, not hidden, until a typeToConfirm phrase matches, and the field's label states the phrase verbatim.
  • A body long enough to scroll (slot content at the default sm size) becomes role="region" with tabindex="0", labelled by the title, so it can be scrolled from the keyboard. NbModal drives that decision from a ResizeObserver on the content box plus a MutationObserver over its contents, so a body that starts out fitting and stops (the window is resized, slot content arrives from a fetch, a translated string wraps onto another line) is caught too. It is marked only while it actually overflows, so a two-line confirm does not grow a stop in its tab order.
  • Under prefers-reduced-motion: reduce the enter and leave transitions run for zero milliseconds. It is written as a duration rather than transition: none for two reasons: the preference can be turned back off while the dialog is open and a none left on a recycled node cannot be undone, and the same number is what the queue waits before showing the next question, so a user who asked for less motion is not made to wait out an animation that never ran. Nothing else here moves.