Skip to content

Alert Dialog

A neo-brutalist confirmation dialog that requires user interaction. Built on top of reka-ui's AlertDialog primitive.

Demo

Preview

Installation

pnpm dlx brutx-vue@latest add alert-dialog

Usage

vue
<script setup>
import { AlertDialogRoot as AlertDialog, AlertDialogTrigger } from 'reka-ui'
import { AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel } from 'brutx-ui-vue'
import { Button } from 'brutx-ui-vue'
</script>

<template>
    <AlertDialog>
        <AlertDialogTrigger as-child>
            <Button variant="danger">Delete Account</Button>
        </AlertDialogTrigger>
        <AlertDialogContent>
            <AlertDialogHeader>
                <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
                <AlertDialogDescription>
                    This action cannot be undone. This will permanently delete your account and remove your data.
                </AlertDialogDescription>
            </AlertDialogHeader>
            <AlertDialogFooter>
                <AlertDialogCancel>Cancel</AlertDialogCancel>
                <AlertDialogAction>Continue</AlertDialogAction>
            </AlertDialogFooter>
        </AlertDialogContent>
    </AlertDialog>
</template>

Sub-components

ComponentDescription
AlertDialogRoot component (import directly from reka-ui: import { AlertDialogRoot as AlertDialog } from 'reka-ui')
AlertDialogTriggerButton that opens the dialog (import directly from reka-ui: import { AlertDialogTrigger } from 'reka-ui')
AlertDialogPortalPortal component (import directly from reka-ui: import { AlertDialogPortal } from 'reka-ui')
AlertDialogContentDialog content panel
AlertDialogHeaderHeader container for title and description
AlertDialogFooterFooter container for action buttons
AlertDialogTitleDialog title
AlertDialogDescriptionDialog description text
AlertDialogActionConfirm action button
AlertDialogCancelCancel button that closes the dialog

Props

AlertDialogContent

PropTypeDefaultDescription
classstringCustom CSS class

AlertDialogHeader

PropTypeDefaultDescription
classstringCustom CSS class

AlertDialogFooter

PropTypeDefaultDescription
classstringCustom CSS class

AlertDialogTitle

PropTypeDefaultDescription
classstringCustom CSS class

AlertDialogDescription

PropTypeDefaultDescription
classstringCustom CSS class

AlertDialogAction

PropTypeDefaultDescription
variant'default' | 'primary' | 'secondary' | 'accent' | 'danger' | 'success' | 'outline' | 'ghost' | 'link''default'Button variant
classstringCustom CSS class
asstring | ComponentRender as a specified element or component
asChildbooleanWhether to render as child element

AlertDialogCancel

PropTypeDefaultDescription
classstringCustom CSS class

AlertDialogCancel uses a hardcoded variant: 'outline'.

Slots

SlotScopeDescription
defaultAll sub-components support the default slot for inserting custom content

Accessibility

  • Keyboard: Press Escape to close the dialog; AlertDialogCancel closes the dialog on click; AlertDialogAction confirms and closes the dialog
  • ARIA Attributes: The dialog uses the semantic role="alertdialog" attribute
  • Focus Management: When the dialog opens, focus is trapped inside

Brute force builds.