Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

Overlays & Actions

Alert Dialog

Modal confirmation pattern: explicit continue/cancel, optional media slot, compact size, destructive actions. Content uses Dialog presentation="slot" (custom overlay). Reveal the right amount of context without losing the user's place in the interface. Keep the trigger, content and dismissal behavior working as one interaction. Import it from @/components/kamod-ui/alert-dialog.

Source · Design reference · API reference · Theming · Styles


Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Installation

Import alert dialog primitives from @/components/kamod-ui/alert-dialog. Motion is optional — core @kamod-ch/ui includes CSS enter/exit on AlertDialogContent.

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.

Usage

Compose Trigger (often asChild + Button), Content, Header (title + description), and Footer (Cancel + Action). Cancel and Action close the dialog on click.

Usage PatternTypeScript
<AlertDialog>
  <AlertDialogTrigger>Delete account</AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogTitle>Delete account?</AlertDialogTitle>
      <AlertDialogDescription>
        This action is permanent.
      </AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogCancel>Cancel</AlertDialogCancel>
      <AlertDialogAction>Continue</AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>
Usage PatternTypeScript
<AlertDialog>
  <AlertDialogTrigger asChild>
    <Button variant="outline">Open</Button>
  </AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogTitle>Title</AlertDialogTitle>
      <AlertDialogDescription>Description</AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogCancel>Cancel</AlertDialogCancel>
      <AlertDialogAction>Continue</AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>

Component Examples & Variants

Explore Alert Dialog in Different Contexts, from the starting pattern to the compositions below. Begin with Basic, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.

Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.

Basic

Reserve Confirmation for Consequential Decisions. Compose AlertDialogTitle, AlertDialogDescription and the footer actions into one decision. The title names what will happen, the description explains its consequence, and Cancel gives the reader an explicit way back.

Keep cancellation available and connect the confirmed action to your own operation, including pending and failure handling.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Small

Use a Compact Panel for a Short Decision. Set size="sm" on AlertDialogContent when the decision fits in a short explanation. This narrows the panel while retaining the same title, description and action structure as the full-size example.

It changes presentation, not the importance of the confirmation; test longer translated labels before choosing this density.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Media

Give the Decision a Recognizable Visual Cue. Place a relevant symbol inside AlertDialogMedia above the title to establish context before the reader reaches the decision. The graphic supports the explanation; the dialog's accessible name still comes from its title.

Mark a purely decorative symbol appropriately so it is not announced as a second title. Check the dialog without the graphic to confirm the text still identifies the affected resource and the decision being requested.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Small with Media

Balance a Visual Cue with Concise Copy. Combine AlertDialogMedia with size="sm" on the content panel for a concise device or connection prompt. The illustration, explanation and actions remain in the same reading order within the smaller surface.

Keep the graphic small enough to leave room for the consequences and action labels, especially when the viewport or translated copy is narrow.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Destructive

Make the Consequence Explicit. Use variant="destructive" on AlertDialogAction and destructive theme tokens on the media to reinforce the consequence. An outlined cancel action offers a visually distinct alternative without changing the confirmation workflow.

Before connecting the handler, test a long resource name and translated action labels in the panel. Keep the dangerous operation separate from Cancel and show pending or failure feedback if confirmation starts asynchronous work.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width
API reference

Props and Data

Configure Alert Dialog using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.

Props overview.

API reference
Your API, from source

Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.

Component Props

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.
@kamod-ch/ui/alert-dialog43.6 KB min · 10.4 KB gzipSignals: via dialog@preact/signals

AlertDialog

AlertDialogProps

AlertDialog documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildAlertDialogProps

Configure children for AlertDialog. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
defaultOpen
booleanAlertDialogProps

Configure defaultOpen for AlertDialog. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
dismissible
booleanAlertDialogProps

When false, Escape and an overlay click leave the dialog open. An explicit close control still closes it. Default true.

Default
—
lockBodyScroll
booleanAlertDialogProps

When true, locks document scroll while open (shadcn default).

Default
—
onOpenChange
((open: boolean) => void)AlertDialogProps

Configure onOpenChange for AlertDialog. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
open
booleanAlertDialogProps

Configure open for AlertDialog. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

AlertDialogAction

AlertDialogActionProps

AlertDialogAction documented props
Prop / typeDescription
asChild
booleanAlertDialogActionProps

Configure asChild for AlertDialogAction. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
children
ComponentChild[] | ComponentChildAlertDialogActionProps

Configure children for AlertDialogAction. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>AlertDialogActionProps

Configure class for AlertDialogAction. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
data-slot
stringAlertDialogActionProps

Configure data-slot for AlertDialogAction. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
variant
"default" | "destructive" | "secondary" | "link" | "inverse" | "outline" | "ghost"AlertDialogActionProps

Configure variant for AlertDialogAction. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"default"

AlertDialogCancel

AlertDialogCancelProps

AlertDialogCancel documented props
Prop / typeDescription
asChild
booleanAlertDialogCancelProps

Configure asChild for AlertDialogCancel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
children
ComponentChild[] | ComponentChildAlertDialogCancelProps

Configure children for AlertDialogCancel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>AlertDialogCancelProps

Configure class for AlertDialogCancel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
data-slot
stringAlertDialogCancelProps

Configure data-slot for AlertDialogCancel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
variant
"default" | "destructive" | "secondary" | "link" | "inverse" | "outline" | "ghost"AlertDialogCancelProps

Configure variant for AlertDialogCancel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"outline"

AlertDialogContent

AlertDialogContentProps

AlertDialogContent documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildAlertDialogContentProps

Configure children for AlertDialogContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>AlertDialogContentProps

Configure class for AlertDialogContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
data-slot
stringAlertDialogContentProps

Configure data-slot for AlertDialogContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
forceMount
booleanAlertDialogContentProps

Configure forceMount for AlertDialogContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
getInitialFocus
((panel: HTMLElement) => HTMLElement | null | undefined)AlertDialogContentProps

Override the default focus target when the modal opens (for example AlertDialog cancel).

Default
—
presentation
DialogContentPresentationAlertDialogContentProps

`modal` — built-in overlay + centered panel + optional corner close. `slot` — one portaled element only; use when **you** provide overlay + panel (legacy fullscreen `DialogContent` pattern with `fixed inset-0 …`).

Default
—
role
((AriaRole | SignalLike<AriaRole | undefined>) & ("alertdialog" | "dialog"))AlertDialogContentProps

Configure role for AlertDialogContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
showCloseButton
booleanAlertDialogContentProps

Configure showCloseButton for AlertDialogContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
size
AlertDialogContentSizeAlertDialogContentProps

`sm` — narrower panel (shadcn parity).

Default
"default"

AlertDialogDescription

AlertDialogDescriptionProps

AlertDialogDescription documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildAlertDialogDescriptionProps

Configure children for AlertDialogDescription. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>AlertDialogDescriptionProps

Configure class for AlertDialogDescription. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

AlertDialogFooter

AlertDialogFooterProps

AlertDialogFooter documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildAlertDialogFooterProps

Configure children for AlertDialogFooter. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>AlertDialogFooterProps

Configure class for AlertDialogFooter. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

AlertDialogHeader

AlertDialogHeaderProps

AlertDialogHeader documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildAlertDialogHeaderProps

Configure children for AlertDialogHeader. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>AlertDialogHeaderProps

Configure class for AlertDialogHeader. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

AlertDialogMedia

AlertDialogMediaProps

AlertDialogMedia documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildAlertDialogMediaProps

Configure children for AlertDialogMedia. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>AlertDialogMediaProps

Configure class for AlertDialogMedia. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

AlertDialogTitle

AlertDialogTitleProps

AlertDialogTitle documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildAlertDialogTitleProps

Configure children for AlertDialogTitle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>AlertDialogTitleProps

Configure class for AlertDialogTitle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

AlertDialogTrigger

AlertDialogTriggerProps

AlertDialogTrigger documented props
Prop / typeDescription
asChild
booleanAlertDialogTriggerProps

Configure asChild for AlertDialogTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
children
ComponentChild[] | ComponentChildAlertDialogTriggerProps

Configure children for AlertDialogTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>AlertDialogTriggerProps

Configure class for AlertDialogTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
data-slot
stringAlertDialogTriggerProps

Configure data-slot for AlertDialogTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

Data Type Reference

Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.

AlertDialog Props

1 declared field
AlertDialogProps
Exported Source Declaration from AlertDialog.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of AlertDialogProps before adapting it.

AlertDialogAction Props

2 declared fields
AlertDialogActionProps
Exported Source Declaration from AlertDialogAction.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of AlertDialogActionProps before adapting it.

AlertDialogCancel Props

2 declared fields
AlertDialogCancelProps
Exported Source Declaration from AlertDialogCancel.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of AlertDialogCancelProps before adapting it.
AlertDialogContentSize
Exported Source Declaration from AlertDialogContent.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of AlertDialogContentSize before adapting it.

AlertDialogContent Props

2 declared fields
AlertDialogContentProps
Exported Source Declaration from AlertDialogContent.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of AlertDialogContentProps before adapting it.
AlertDialogDescriptionProps
Exported Source Declaration from AlertDialogDescription.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of AlertDialogDescriptionProps before adapting it.

AlertDialogFooter Props

1 declared field
AlertDialogFooterProps
Exported Source Declaration from AlertDialogFooter.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of AlertDialogFooterProps before adapting it.

AlertDialogHeader Props

1 declared field
AlertDialogHeaderProps
Exported Source Declaration from AlertDialogHeader.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of AlertDialogHeaderProps before adapting it.

AlertDialogMedia Props

1 declared field
AlertDialogMediaProps
Exported Source Declaration from AlertDialogMedia.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of AlertDialogMediaProps before adapting it.

AlertDialogTitle Props

1 declared field
AlertDialogTitleProps
Exported Source Declaration from AlertDialogTitle.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of AlertDialogTitleProps before adapting it.

AlertDialogTrigger Props

1 declared field
AlertDialogTriggerProps
Exported Source Declaration from AlertDialogTrigger.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of AlertDialogTriggerProps before adapting it.

Accessibility

Build the Complete Interaction, Including the Parts Outside Alert Dialog. The notes below distinguish the current implementation from the labels, content and behavior your application supplies. Start with the Live Preview, check the Props and Data Reference, and test the finished composition with real content rather than assuming that an unchanged visual example covers every use case.

Built-in Behavior and Defaults

AlertDialog wraps Kamod Dialog and locks body scrolling. AlertDialogContent uses the slot presentation with role="alertdialog", its own overlay and panel, and initial focus on Cancel when that action is present (otherwise the portaled root panel).

Labels and Relationships

State the specific consequence in the title and explanation: identify what will be deleted or changed. Use explicit action text such as Delete workspace, and provide an equally understandable cancellation action.

Keyboard and Focus

Verify initial focus lands on Cancel when provided, then test Tab order, Escape dismissal and return focus to the trigger. Confirm the destructive action remains reachable without bypassing the confirmation copy your product requires.

States and Integration Details

Do not use a destructive color as the only warning, and do not claim that this wrapper prevents every accidental dismissal. Handle pending, failed and completed actions without closing the dialog before an error can be understood.

Verify the Complete Interaction

Check Behavior as Well as Markup. Work through these scenarios in the application where the component will be used. Automated checks can help find structural problems; also review the reading experience with a screen reader, keyboard focus and the actual feedback from your application.

  1. Open with the keyboard and confirm the initial focus target is appropriate for the consequence.
  2. Read the title, object name and both actions using a screen reader.
  3. Test cancellation, Escape and a rejected request while keeping a safe way to recover.

Recheck the result after changing Theme Tokens, translations or class overrides. Include text enlargement, narrow layouts and reduced-motion settings where animation is present. Inspect the Component Source when a behavior differs from your expectation; a role or state attribute does not implement keyboard interaction by itself.

For background, read the WAI-ARIA Authoring Guidance and Keyboard Interface Guidance. These explain the patterns; verify browser and assistive-technology behavior for the implementation and audience you actually support.

Take the Next Useful Step

You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.

Connect the Foundation

Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.

Build the Surrounding Screen

Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.

Make the Result Hold Up

Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.

Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.