Alert Dialog

A modal dialog that interrupts the user with important content and expects a response.

Component Code
<april:alert-dialog>
<slot:trigger>
<april:button variant="outline">Delete account</april:button>
</slot:trigger>
<slot:content>
<april:alert-dialog-header>
<slot:title>Are you absolutely sure?</slot:title>
<slot:description>This action cannot be undone. This will permanently delete your account and remove your data from our servers.</slot:description>
</april:alert-dialog-header>
<april:alert-dialog-footer>
<april:alert-dialog-cancel>Cancel</april:alert-dialog-cancel>
<april:alert-dialog-action type="button">Continue</april:alert-dialog-action>
</april:alert-dialog-footer>
</slot:content>
</april:alert-dialog>

Use an alert dialog for destructive or consequential actions. The dialog stays open until the user chooses an action.

<april:alert-dialog>
<slot:trigger><april:button>Delete account</april:button></slot:trigger>
<slot:content>
<april:alert-dialog-header>
<slot:title>Delete account?</slot:title>
<slot:description>This action cannot be undone.</slot:description>
</april:alert-dialog-header>
<april:alert-dialog-footer>
<april:alert-dialog-cancel>Cancel</april:alert-dialog-cancel>
<april:alert-dialog-action>Delete</april:alert-dialog-action>
</april:alert-dialog-footer>
</slot:content>
</april:alert-dialog>

The trigger, content, title, and description regions are named slots. The footer uses its default slot because it can contain multiple actions.

Submit a form

The action uses type="button" by default. Set type="submit" to submit a form after confirmation. Use form to name the form when the dialog content is outside it, including teleported content.

<form id="delete-program" method="POST" action="/programs/1">
@csrf
@method('DELETE')
</form>
<april:alert-dialog x-teleport="body">
<slot:trigger><april:button>Delete program</april:button></slot:trigger>
<slot:content>
<april:alert-dialog-header>
<slot:title>Delete this program?</slot:title>
</april:alert-dialog-header>
<april:alert-dialog-footer>
<april:alert-dialog-cancel>Cancel</april:alert-dialog-cancel>
<april:alert-dialog-action type="submit" form="delete-program">Delete</april:alert-dialog-action>
</april:alert-dialog-footer>
</slot:content>
</april:alert-dialog>

Publishing Views

Use the following commands to publish these views:

php artisan april:publish alert-dialog
php artisan april:publish alert-dialog-header
php artisan april:publish alert-dialog-footer
php artisan april:publish alert-dialog-action
php artisan april:publish alert-dialog-cancel
April UI keeps package views in `vendor/` by default. The command uses Laravel's vendor publishing system and copies overrides to `resources/views/vendor/april/components`. To publish all components, run:
php artisan april:publish --all
Review local overrides after an upgrade with `php artisan april:update --diff`.