Download the PHP package abdelhamiderrahmouni/blade-component-scopes without Composer
On this page you can find all versions of the php package abdelhamiderrahmouni/blade-component-scopes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download abdelhamiderrahmouni/blade-component-scopes
More information about abdelhamiderrahmouni/blade-component-scopes
Files in abdelhamiderrahmouni/blade-component-scopes
Package blade-component-scopes
Short Description Scope attributes to specific elements within your Blade components.
License MIT
Informations about the package blade-component-scopes
Scopes for Laravel Blade Components
This package allows you to scope attributes to specific elements within your Blade components.
Installation
Requires php 8.2+ and Laravel 10+
First, install Scopes for Laravel Blade Components
via composer:
Usage
This package adds a scope()
macro to Laravel's ComponentAttributeBag,
allowing you to namespace your component attributes for different elements of your component.
Basic Example
In your component view, access scoped attributes using the scope() method:
How It Works
The scope()
method filters attributes based on the prefix. For example:
- The label's class in
label:class="font-bold"
becomes available when using$attributes->scope('label')
- The input's ID in
input:id="first-name-input"
becomes available when using$attributes->scope('input')
- The container's class in
container:class="mt-4"
becomes available when using$attributes->scope('container')
This allows you to:
- Organize attributes for different elements/parts of your component
- Create more intuitive component interfaces
- Maintain cleaner component templates
Benefits
- 🎯 Better organization of component attributes
- 🔍 More explicit attribute targeting
- 🧩 Cleaner components with less clutter
- 💪 Fully compatible with Laravel's existing attribute merging
If you want to benifit from the
scope
method in your Blade views without installing this package, here is the magic sauce:
Add the following code to your AppServiceProvider
:
Contributing
Thank you for considering contributing to Scopes for Laravel Blade Components
! The contribution guide can be found in the CONTRIBUTING.md file.
Scopes for Laravel Blade Components
is an open-sourced software licensed under the MIT license.
All versions of blade-component-scopes with dependencies
guzzlehttp/guzzle Version ^7.5.1
laravel/framework Version ^10.0|^11.0|^12.0