Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Livewire

Component Attributes in Livewire v4: Forwarding HTML Attributes

Pass HTML attributes directly to Livewire components like Blade components.

1 February 20261 min readLivewireاقرأ بالعربية

On this page

  1. Usage
  2. Component

Livewire v4 adds support for forwarding HTML attributes to components.

Usage

blade
<wire:alert type="error" class="mb-4" id="error-alert">
    Something went wrong!
</wire:alert>

Component

php
@php
new class extends Livewire\Component {
    #[Prop]
    public string $type = 'info';
}
@endphp

<div {{ $attributes->merge(['class' => 'alert alert-'.$type]) }}>
    {{ $slot }}
</div>
All articles

Keep reading

  • Authorization in Livewire v4 Components1 February 20261 min read
  • Blaze Pre-Compiler: Massive Performance Gains in Livewire v41 February 20261 min read
  • Building a Bookmark Feature with Livewire v41 February 20261 min read