Day 3 - Component Challenge

Challenge UI with Livewire & Alpine.js

Day 3

Day 3

Alert & Modal Components

Beautiful alerts with variants and modals with Alpine.js state management

Alert Component

Contextual messages with beautiful variants and icons

Alert Variants

Dismissible Alerts with Titles

Modal Component

Dialogs with Alpine.js state management and smooth transitions

Modal Sizes

Real-world Examples

Combined Example

Alert and Modal working together for a complete UX

Component API Reference

Alert Component

Prop Type Default Description
variant string 'info' success, error, warning, info
dismissible boolean false Show close button
title string null Optional title
icon string auto Custom Lucide icon

Modal Component

Prop Type Default Description
id string 'modal' Unique identifier for events
size string 'md' sm, md, lg, xl, 2xl, 3xl, 4xl, full
closeable boolean true Allow closing (X, ESC, click outside)
title string null Optional modal title
footer slot null Named slot for footer actions

Usage Examples

Alert Usage

<x-ui.alert variant="success" :dismissible="true" title="Success">
Your changes have been saved!
</x-ui.alert>
 
<x-ui.alert variant="error" :dismissible="true" title="Error">
Something went wrong. Please try again.
</x-ui.alert>
 
<x-ui.alert variant="warning" title="Warning">
Your session will expire in 5 minutes.
</x-ui.alert>
 
<x-ui.alert variant="info" icon="info">
New features are now available!
</x-ui.alert>

Modal Usage

<!-- Trigger -->
<x-ui.button x-on:click="$dispatch('open-modal-example')">
Open Modal
</x-ui.button>
 
<!-- Modal -->
<x-ui.modal id="example" size="md" title="Example Modal">
<p class="text-muted-foreground">
This is a modal dialog with Alpine.js state management.
</p>
 
<x-slot:footer>
<div class="flex items-center justify-end gap-2">
<x-ui.button
variant="ghost"
x-on:click="$dispatch('close-modal-example')"
>
Cancel
</x-ui.button>
<x-ui.button
variant="primary"
x-on:click="$dispatch('close-modal-example')"
>
Confirm
</x-ui.button>
</div>
</x-slot:footer>
</x-ui.modal>