Laravel Volt is an optional companion to Livewire 3 that introduces a single-file component API. Both the PHP logic and Blade template live in a single .blade.php file.
<?php
use function Livewire\Volt\{state, computed};
state(['count' => 0]);
$increment = fn () => $this->count++;
$total = computed(fn () => $this->count * 2);
?>
<div>
<h1>Count: {{ $count }}</h1>
<h2>Total: {{ $this->total }}</h2>
<button wire:click="increment">Increment</button>
</div>
composer require livewire/volt
php artisan volt:install
Volt is best suited for smaller, self-contained components such as forms, modals, and counters.
All Comments