Skip to content
ARC UI ARC Reactive Components
Docs Components Tokens Synthesizer
v2.1.0
Getting Started Frameworks Design Tokens Theming Theme Synthesizer Accessibility Browser Support Changelog Contributing All Components App ShellAspect GridAuth ShellCenterClusterContainerDashboard GridDockFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbar Anchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkSpeed DialStepper NavTabsTop BarTree View AccordionAspect RatioAvatarAvatar GroupCalloutCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageInfinite ScrollMarqueeScroll AreaSeparatorSkeletonSpinnerStackVirtual List Animated NumberBadgeComparisonCountdown TimerData TableDescription ListDiffKey ValueListMeterSparklineStatStepperTableTagTimelineValue Card BlockquoteCode BlockGradient TextHighlightKbdMarkdownNumber FormatProseTextTime AgoTruncateTypewriter ButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerFieldsetFile UploadFormHotkeyIcon ButtonInputInput GroupLabelMulti SelectNumber InputOTP InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSliderSortable ListSwitch GroupTextareaTheme ToggleTime PickerToggle AlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuDialogDropdown MenuGuided TourHover CardInline MessageLoading OverlayModalNotification PanelPopoverProgressProgress ToastSheetSnackbarSpotlightToastTooltip
Components Dialog
feedback interactive
<arc-dialog>

Overview

Guidelines

When to use

  • Use Dialog for urgent, interruptive prompts — unsaved changes, session expiry, discard warnings
  • Keep the message concise — one or two sentences explaining what will happen
  • Use variant="danger" when the confirmed action is destructive or irreversible
  • Use the confirm() promise API for cleaner async flow in your logic
  • Set specific button labels: "Discard Changes" is clearer than "Confirm"

When not to use

  • Use Dialog for complex forms or rich content — use Modal instead
  • Stack multiple dialogs — resolve one before opening another
  • Use Dialog for informational messages — use Alert or Toast instead
  • Use Dialog for general-purpose overlays — that's what Modal is for
  • Use variant="danger" for non-destructive confirmations — it creates unnecessary anxiety

Features

  • Centered modal presentation via arc-modal with size="sm"
  • Backdrop with blur effect for focused attention
  • Slide-up entrance animation
  • Delegates to arc-modal for focus trap and Escape key handling
  • Small modal size for compact confirm/cancel prompts
  • Promise-based confirm() API — returns true on confirm, false on cancel/escape
  • Danger variant with red accent line, glow border, and red confirm button
  • Escape key and backdrop click trigger cancellation
  • role="alertdialog" with aria-modal for proper screen reader semantics
  • Customizable button labels via confirm-label and cancel-label attributes

Preview

Discard Draft

Usage

This component requires JavaScript. No pure HTML/CSS version is available — use the Web Component directly or a framework wrapper.

<arc-dialog
  heading="Discard Draft?"
  message="You have unsaved changes that will be permanently lost."
  confirm-label="Discard"
  cancel-label="Keep Editing"
  variant="danger"
></arc-dialog>

<script>
  const dialog = document.querySelector('arc-dialog');
  // Promise-based API
  const confirmed = await dialog.confirm();
  if (confirmed) discardDraft();
</script>
import { Dialog } from '@arclux/arc-ui-react';
import { useRef } from 'react';

function App() {
  const ref = useRef(null);

  const handleDiscard = async () => {
    const confirmed = await ref.current.confirm();
    if (confirmed) discardDraft();
  };

  return (
    <>
      <button onClick={handleDiscard}>Discard</button>
      <Dialog
        ref={ref}
        heading="Discard Draft?"
        message="You have unsaved changes that will be permanently lost."
        confirm-label="Discard"
        cancel-label="Keep Editing"
        variant="danger"
      />
    </>
  );
}
<script setup>
import { ref } from 'vue';
import { Dialog } from '@arclux/arc-ui-vue';

const dialogRef = ref(null);

async function handleDiscard() {
  const confirmed = await dialogRef.value.confirm();
  if (confirmed) discardDraft();
}
</script>

<template>
  <button @click="handleDiscard">Discard</button>
  <Dialog
    ref="dialogRef"
    heading="Discard Draft?"
    message="You have unsaved changes that will be permanently lost."
    confirm-label="Discard"
    cancel-label="Keep Editing"
    variant="danger"
  />
</template>
<script>
  import { Dialog } from '@arclux/arc-ui-svelte';
  let dialogEl;

  async function handleDiscard() {
    const confirmed = await dialogEl.confirm();
    if (confirmed) discardDraft();
  }
</script>

<button on:click={handleDiscard}>Discard</button>
<Dialog
  bind:this={dialogEl}
  heading="Discard Draft?"
  message="You have unsaved changes that will be permanently lost."
  confirmLabel="Discard"
  cancelLabel="Keep Editing"
  variant="danger"
/>
import { Component, ViewChild, ElementRef } from '@angular/core';
import { Dialog } from '@arclux/arc-ui-angular';

@Component({
  imports: [Dialog],
  template: `
    <button (click)="handleDiscard()">Discard</button>
    <Dialog #dialog
      heading="Discard Draft?"
      message="You have unsaved changes that will be permanently lost."
      confirmLabel="Discard"
      cancelLabel="Keep Editing"
      variant="danger"
    />
  `,
})
export class MyComponent {
  @ViewChild('dialog') dialog!: ElementRef;

  async handleDiscard() {
    const confirmed = await this.dialog.nativeElement.confirm();
    if (confirmed) this.discardDraft();
  }
}
import { Dialog } from '@arclux/arc-ui-solid';

let dialogEl;

async function handleDiscard() {
  const confirmed = await dialogEl.confirm();
  if (confirmed) discardDraft();
}

<button onClick={handleDiscard}>Discard</button>
<Dialog
  ref={dialogEl}
  heading="Discard Draft?"
  message="You have unsaved changes that will be permanently lost."
  confirmLabel="Discard"
  cancelLabel="Keep Editing"
  variant="danger"
/>
import { Dialog } from '@arclux/arc-ui-preact';
import { useRef } from 'preact/hooks';

function App() {
  const ref = useRef(null);

  const handleDiscard = async () => {
    const confirmed = await ref.current.confirm();
    if (confirmed) discardDraft();
  };

  return (
    <>
      <button onClick={handleDiscard}>Discard</button>
      <Dialog
        ref={ref}
        heading="Discard Draft?"
        message="You have unsaved changes that will be permanently lost."
        confirmLabel="Discard"
        cancelLabel="Keep Editing"
        variant="danger"
      />
    </>
  );
}

API

Prop Type Default Description
open boolean false Whether the dialog is visible
heading string '' Dialog title text
message string '' Dialog body message
confirm-label string 'Confirm' Text for the confirm button
cancel-label string 'Cancel' Text for the cancel button
variant 'default' | 'danger' 'default' Visual variant — danger adds red accent line, glow border, and red confirm button

Events

Event Description
arc-confirm Fired when the confirm button is clicked
arc-cancel Fired when cancel, escape, or backdrop click occurs

See Also