dispatch('openModal', component: 'modals.confirm', arguments: [ * 'title' => ..., 'body' => ..., 'confirmLabel' => ..., 'event' => 'someEvent', 'danger' => true, * ]); * On confirm it dispatches `event` (caught by the opener via #[On('someEvent')]) and closes. */ class Confirm extends ModalComponent { public string $title = ''; public string $body = ''; public string $confirmLabel = ''; public string $event = ''; public string $to = ''; public bool $danger = false; public static function modalMaxWidth(): string { return 'md'; } public function mount(string $title, string $body, string $confirmLabel, string $event, string $to = '', bool $danger = false): void { $this->title = $title; $this->body = $body; $this->confirmLabel = $confirmLabel; $this->event = $event; $this->to = $to; $this->danger = $danger; } public function confirm(): void { // Target the opener (if given) so an event name can't collide with another component. $this->to !== '' ? $this->dispatch($this->event)->to($this->to) : $this->dispatch($this->event); $this->closeModal(); } public function render() { return view('livewire.modals.confirm'); } }