Parent-Child Communication in Livewire v4
February 01, 2026
•
1 min read
•
49 views
Table of Contents
Livewire v4 provides multiple ways for component communication.
Props - Passing Data Down
// Parent Component View
// Child Component
class ChildComponent extends Component
{
public User $user;
public Collection $posts;
public string $title;
public function mount(User $user, Collection $posts, string $title): void
{
$this->user = $user;
$this->posts = $posts;
$this->title = $title;
}
}Events - Dispatching Up
// Child Component - dispatch event to parent
class ItemSelector extends Component
{
public function selectItem(int $id): void
{
$this->dispatch('item-selected', id: $id, name: 'Product');
}
}
// Parent Component - listen for event
class ParentComponent extends Component
{
public ?int $selectedItemId = null;
#[On('item-selected')]
public function handleSelection(int $id, string $name): void
{
$this->selectedItemId = $id;
session()->flash('message', "Selected: {$name}");
}
}Two-Way Binding with wire:model
// Parent using wire:model
// Child Component (ColorPicker)
class ColorPicker extends Component
{
#[Modelable]
public string $value = '#000000';
public function render()
{
return view('livewire.color-picker');
}
}
Related Posts
Introduction to Livewire v4: The Future of Laravel Full-Stack Development
Discover what's new in Livewire v4 and why it's a game-changer for Laravel developers.
Single-File Components in Livewire v4: The View-First Approach
Learn how to create single-file components with the new .wire.php extension.
Multi-File Components (MFC) in Livewire v4
Organize complex components with the new multi-file component structure.
Comments (0)
No comments yet. Be the first to comment!