Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Blade X Laravel Package

spatie/laravel-blade-x

Blade-X brings Blade-style HTML components to Laravel 6 and below, letting you use tags like instead of @include. Package is abandoned because Laravel 7+ has native Blade components; migrate when upgrading.

View on GitHub
Deep Wiki
Context7

title: Using variables weight: 2

When using a BladeX component all attributes will be passed as variables to the underlying Blade view.

{{-- the `myAlert` view will receive a variable named `type` with a value of `error` --}}

<my-alert type="error">

If you want to pass on a PHP variable or something that needs to be evaluated you must prefix the attribute name with :.

{{-- the `myAlert` view will receive the contents of `$message` --}}
<my-alert type="error" :message="$message">

{{-- the `myAlert` view will receive the uppercased contents of `$message` --}}
<my-alert type="error" :message="strtoupper($message)">

Spread operator for attributes

Passing an array of component attributes to a BladeX component can be achieved using the spread operator:

<text-input ...$input />

Combining multiple destructured arrays and normal attributes is supported too! Normal attributes will override attributes in the spreaded attributes array.

<text-field
    label="E-Mail"
    ...$input
    ...$email
    :var="$foo"
/>

Boolean attributes

Boolean attributes (attributes without a value), e.g. <checkbox checked /> will be passed to the component as variables evaluating to true.

{{-- the `checkboxInput` view will receive a `$checked` variable that evaluates as true --}}
<checkbox-input checked />
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport