Getting startedComponentsDesign tokensThemingTheme synthesizerFrameworksAccessibilityUtilitiesServer renderingBrowser supportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting startedFrameworksServer renderingDesign tokensThemingTheme synthesizerTypographyUtilitiesAll componentsAccessibilityBrowser supportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Confirm

Confirmation prompt built on Dialog. Call ArcConfirm.open() and await a true or false answer.

ComponentsConfirm
feedbackinteractive
<arc-confirm>

Overview

Confirm asks a yes-or-no question in a small dialog with a cancel button and a confirm button. It comes in two shapes. `await ArcConfirm.open({ heading, message, ... })` creates a prompt, resolves to `true` on confirm and `false` on cancel, then removes the element. Use it at a call site that has to decide before it continues. The `<arc-confirm>` element is for templates: bind `open` and listen for `arc-confirm` and `arc-cancel`. Its default slot takes body markup the `message` string can't carry, such as a filename in `<code>`. It's built on Dialog, so it has the same blurred backdrop, raised panel and focus trap. Escape, a backdrop click and the X button all count as cancel. `variant="error"` turns the confirm button the error color. **Upgrading from v3:** the `arc-dialog` tag used to be this prompt. In v4, `arc-dialog` is the overlay primitive (renamed from `arc-modal`), and the prompt's props (`heading`, `message`, `confirm-label`, `cancel-label`, `variant`) moved here. `variant="danger"` is now `variant="error"`. A leftover `"danger"` falls back to the default variant with no warning, so the confirm button loses its error color.

Guidelines

Do

  • Use `variant="error"` when the action deletes something
  • Write a heading that names the action: "Delete project?", not "Are you sure?"
  • Label the buttons with what they do, such as "Delete" and "Keep", not "OK" and "Cancel"
  • With the element, one `<arc-confirm>` can serve every prompt. Set its props before you open it

Don't

  • Don't use it for a message that needs no decision. Use Alert or Dialog
  • Don't chain confirmations. If the action needs more context, use a Dialog with a form
  • Don't confirm every action. Save it for ones that are destructive or can't be undone
  • Don't use the browser's `confirm()`. It blocks the page and can't be styled

Features

  • `ArcConfirm.open()` takes `heading`, `message`, `confirmLabel`, `cancelLabel` and `variant`. Its body can only be the `message` string
  • Button labels default to "Confirm" and "Cancel"
  • In the slot, `<code>` gets the mono font and `<strong>` the primary text color

Preview

Delete itemConfirm action

Usage

This component needs JavaScript. Use the Web Component or a framework wrapper.

<script type="module" src="@arclux/arc-ui"></script>

<arc-confirm id="confirm"></arc-confirm>

<arc-button variant="primary"
  onclick="Object.assign(document.getElementById('confirm'), {
    heading: 'Delete this item?',
    message: 'This action cannot be undone.',
    variant: 'error',
    confirmLabel: 'Delete',
    cancelLabel: 'Keep',
    open: true
  })">
  Delete Item
</arc-button>

API

openbooleanfalse
Controls whether the confirmation dialog is visible. For declarative usage; the imperative API manages this automatically.
headingstring''
The heading text displayed at the top of the confirmation dialog.
messagestring''
The body message explaining what the user is confirming. Used as the fallback for the default slot, so it is the simplest way to set the body and the only one available to the imperative ArcConfirm.open() API.
confirm-labelstring'Confirm'
Label for the confirm button. Use a specific verb like "Delete" or "Publish" instead of generic "OK".
cancel-labelstring'Cancel'
Label for the cancel button. Use a specific alternative like "Keep" or "Go back" when possible.
variant'default' | 'error''default'
Controls the confirm button style. Use "error" for destructive actions; the confirm button renders in the error color.

Events

arc-confirm
Fired when the user clicks the confirm button
arc-cancel
Fired when the user clicks cancel, presses Escape, or clicks the backdrop

See also