Laravel

Livewire Modal Components Pattern

January 16, 2026 1 min read 16 views

Reusable modals:

Modal Component

class ConfirmModal extends Component
{
    public bool $show = false;
    public string $title = '';
    public string $message = '';

    #[On('open-confirm')]
    public function open($title, $message)
    {
        $this->title = $title;
        $this->message = $message;
        $this->show = true;
    }

    public function confirm()
    {
        $this->dispatch('confirmed');
        $this->show = false;
    }
}

Usage



Share this post:

Related Posts

Comments (0)

Please log in to leave a comment. Log in

No comments yet. Be the first to comment!