Components
ConfirmationDialog
ConfirmationDialog presents a stack of actions that asks the user to confirm an intent. It aligns with SwiftUI's confirmationDialog mental model while using web-native dialog semantics.
Example
Requires React 18.2+ or 19 and shared styles. See setup.
Default
Loading preview…
Code
'use client';
import { useState } from 'react';
import { Button } from '@swiftuijs/ui';
import { ConfirmationDialog } from '@swiftuijs/ui';
function DefaultDialog() {
const [isVisible, setIsVisible] = useState(false);
return (<>
<Button onClick={() => setIsVisible(true)}>Show Confirmation Dialog</Button>
<ConfirmationDialog title="Delete draft?" message="This action cannot be undone." isVisible={isVisible} onDismiss={() => setIsVisible(false)} actions={[
{ label: 'Delete', style: 'destructive', action: () => setIsVisible(false) },
{ label: 'Cancel', style: 'cancel', action: () => setIsVisible(false) },
]}/>
</>);
}
export default function Example() {
return (<DefaultDialog />);
}Usage and limitations
- Use
actionsto declare the available choices. cancelanddestructiveaction styles mirror Apple's emphasis rules.- The dialog dismisses on action selection, backdrop click, or
Escape. - The bottom surface leaves space for the home indicator and scrolls on short screens. On wide screens it stays horizontally centered at a maximum width of 420px; automatic iPad-style popover adaptation is not implemented.
API reference
| Prop | Type | Required | Description |
|---|---|---|---|
title | string | No | Optional title shown above the actions. |
message | string | No | Optional supporting message. |
isVisible | boolean | Yes | Whether the dialog is currently visible. |
onDismiss | () => void | Yes | Called when the dialog should close. |
actions | IConfirmationDialogAction[] | Yes | Available actions. |
Inherits additional props from IBaseComponent.