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 1mo ago

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 37% 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

1348d 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

[robsontenorio/mary

Gorgeous UI components for Livewire powered by daisyUI and Tailwind

1.5k454.7k15](/packages/robsontenorio-mary)[victorybiz/laravel-simple-select

Laravel Simple Select inputs component for Blade and Livewire.

13721.1k](/packages/victorybiz-laravel-simple-select)[victorybiz/laravel-tel-input

Laravel Telephone Input component for Blade and Livewire based on the intl-tel-input JavaScript plugin.

54127.8k1](/packages/victorybiz-laravel-tel-input)[stijnvanouplines/blade-country-flags

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

26307.2k6](/packages/stijnvanouplines-blade-country-flags)[saade/blade-iconsax

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

21138.5k](/packages/saade-blade-iconsax)[mckenziearts/blade-untitledui-icons

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

16104.9k5](/packages/mckenziearts-blade-untitledui-icons)

PHPackages © 2026

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