PHPackages                             stephancasas/blade-wants-attributes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. stephancasas/blade-wants-attributes

ActiveLibrary[Templating &amp; Views](/categories/templating)

stephancasas/blade-wants-attributes
===================================

Provide all attributes (including irregular patterns) to Laravel Blade class components.

1.0.1(3y ago)711MITPHPPHP ^7.4|^8.0

Since Aug 30Pushed 3y ago1 watchersCompare

[ Source](https://github.com/stephancasas/laravel-blade-wants-attributes)[ Packagist](https://packagist.org/packages/stephancasas/blade-wants-attributes)[ Docs](https://github.com/stephancasas/laravel-blade-wants-attributes)[ RSS](/packages/stephancasas-blade-wants-attributes/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

blade-wants-attributes
======================

[](#blade-wants-attributes)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bda4ce450558cd105135ceb35c216bd82731da87f1c84bc4f116ef2fad209ca3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7374657068616e63617361732f626c6164652d77616e74732d617474726962757465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stephancasas/blade-wants-attributes) [![Total Downloads](https://camo.githubusercontent.com/908dc2c63714547bf7c598ec0a1e328ec69df93f097d06550a25a2f22a974ab6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7374657068616e63617361732f626c6164652d77616e74732d617474726962757465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stephancasas/blade-wants-attributes)

`blade-wants-attributes` offers you the ability to use Blade/HTML-defined attributes within the constructors of Laravel Blade class components.

### Why?

[](#why)

Blade class components have many advantages, but require developers to declare attributes as constructor arguments if they wish to use them in the class signature. Because of this requirement, attributes containing non-standard characters (e.g. `wire:model`, `wire:model.defer`, etc.) are completely inaccessible to the class constructor or methods called by the class constructor.

`blade-wants-attributes` registers a Blade pre-compiler which provides attributes to the `ViewServiceProvider` just prior to initialization of a component instance. Attributes are then made accessible to your component's constructor by adding the `WantsAttributes` trait to the class signature and calling `$this->wantsAttributes()` in the constructor.

##### *Okay, but why?*

[](#okay-but-why)

It can be useful — particularly if you're writing a components package — to extract complex component logic into class methods. For example, you may — at times — wish to dynamically/conditionally render markup for Livewire or AlpineJS. To do this, you'll need to access non-standard HTML attributes which are unavailable to Blade class components.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require stephancasas/blade-wants-attributes
```

Usage
-----

[](#usage)

Apply the `StephanCasas\BladeWantsAttributes\Traits\WantsAttributes` trait to your class component, and call `$this->wantsAttributes()`.

```
namespace App\View\Components;

use Illuminate\View\Component;

class Select extends Component
{
    use StephanCasas\BladeWantsAttributes\Traits\WantsAttributes;

    public $wireModel;

    public function __construct()
    {
        $this->wantsAttributes();

        $this->wireModel = $this->attributes
            ->get('wire:model');
    }

    //...

    public function render()
    {
        return view('components.select');
    }
}
```

Alternatively, if you do not wish to apply the attribute bag to your component's `$attributes` property, you can also access the provided attributes via the `$this->getAllAttributes()` method:

```
namespace App\View\Components;

use Illuminate\View\Component;

class Select extends Component
{
    use StephanCasas\BladeWantsAttributes\Traits\WantsAttributes;

    public $isLivewire;

    public function __construct()
    {
        $this->isLivewire = $this->getAllAttributes()
            ->has('wire:model');
    }

    //...

    public function render()
    {
        return view('components.select');
    }
}
```

License
-------

[](#license)

MIT — see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

2

Last Release

1399d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b08908046e4b530548a852fd3e41782ea5c4f3063b38af309f1a301f771a263a?d=identicon)[stephancasas](/maintainers/stephancasas)

---

Tags

laravelbladeattributeslaravel-bladestephancasasblade-wants-attributes

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/stephancasas-blade-wants-attributes/health.svg)

```
[![Health](https://phpackages.com/badges/stephancasas-blade-wants-attributes/health.svg)](https://phpackages.com/packages/stephancasas-blade-wants-attributes)
```

###  Alternatives

[blade-ui-kit/blade-icons

A package to easily make use of icons in your Laravel Blade views.

2.5k42.5M402](/packages/blade-ui-kit-blade-icons)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[robsontenorio/mary

Gorgeous UI components for Livewire powered by daisyUI and Tailwind

1.5k570.6k23](/packages/robsontenorio-mary)[hasinhayder/tyro-dashboard

Tyro Dashboard - Beautiful admin dashboard for managing Tyro roles, privileges, users, and settings

5443.8k](/packages/hasinhayder-tyro-dashboard)[technikermathe/blade-lucide-icons

A package to easily make use of Lucide icons in your Laravel Blade views.

18421.4k11](/packages/technikermathe-blade-lucide-icons)[hasinhayder/tyro-login

Tyro Login - Beautiful, customizable authentication views for Laravel 12 &amp; 13

2464.9k6](/packages/hasinhayder-tyro-login)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
