This package allows you to render livewire components like a blade component, giving it attributes, slots etc

Related tags

Laravel x-livewire
Overview

X-livewire

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package allows you to render livewire components like a blade component, giving it attributes, slots etc.

Assuming you wanted to create a livewire component, alert, usually you would render the component by: . However, there a few problems.

  1. You can't allow slots within the component. That is, this is invalid: Alert.
  2. You can't access the $attributes bag. Thus, can't access the $attributes variable directly. That is, if you do this: , you can't access the $title attribute by $attributes->get('title'). Instead, you'd have to make $title a public property in the component. Not to mention, other methods on $attributes are not accessible. Such as ->merge([]), ->whereStartsWith(), etc.

The creator of livewire, Caleb Porzio has made it clear that adding slots, attributes etc are not currently on the roadmap.

That's why I created X-livewire.

With X-Livewire, you can do:

My alert message ">
    
        My alert message
    

And, just like with Blade, you can:

  1. Access the $attributes variable: {{ $attributes->get('title') }},
  2. Access the $slot variable: {{ $slot }}

Installation

You can install the package via composer:

composer require titonova/x-livewire

Usage

  1. After creating your livewire component, make it extend XLivewireBaseComponent rather than Component. ie: class Alert extends XLivewireBaseComponent{
  2. In the view file of the component, e.g alert.blade.php add @setUpXLivewire to the top of the file.
  3. When you want to render the component: Blade My alert message
  4. You can access the $slot and $attributes variables just like you would in a Blade component:
    {{ $slot }}
    {{ $attributes->get('title') }}
    

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

TODO/Roadmap

[ ] Add Tests [ ] Shorten tag declartion to

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.
Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.

About Wire Elements Spotlight Wire Elements Spotlight is a Livewire component that provides Spotlight/Alfred-like functionality to your Laravel applic

A package for defining scoped styles in Livewire components

A package for defining scoped styles in Livewire components

Control frontend access to properties/methods in Livewire using PHP 8 attributes.
Control frontend access to properties/methods in Livewire using PHP 8 attributes.

This package adds PHP 8.0 attribute support to Livewire. In specific, the attributes are used for flagging component properties and methods as frontend-accessible.

Cagilo - a set of simple components for use in your views Laravel Blade.

Cagilo - a set of simple components for use in your views Laravel Blade. Official Documentation Documentation for Cagilo can be found on its we

Useful blade components and functionality for most Laravel projects.

laravel-base Note: Package is still in early stages of development, so functionality is subject to change. LaravelBase is a package I've created to pr

Custom Blade components to add sortable/drag-and-drop HTML elements in your apps.
Custom Blade components to add sortable/drag-and-drop HTML elements in your apps.

Laravel Blade Sortable Demo Repo Installation You can install the package via composer: composer require asantibanez/laravel-blade-sortable After the

A collection of pre-made simple Laravel Blade form components.
A collection of pre-made simple Laravel Blade form components.

Laravel Form Components Library A collection of pre-made simple Laravel Blade form components. Installation & setup You can install the package via co

Auto generate routes for Laravel Livewire components

livewire-auto-routes Auto generate routes for Laravel Livewire Components. Requirements Livewire 2 Laravel 8 php 8 Installation composer require tanth

Livewire DataTables components for back-end. Modular, easy to use, with tons of features.

Livewire DataTables Livewire DataTables components for back-end. Modular, easy to use, with tons of features. Inspired by Caleb's Livewire Screencasts

Releases(1.1.0-beta)
  • 1.1.0-beta(Aug 29, 2022)

    Added the ability to add custom, named slots to <x-livewire> components, just like normal blade components.

    For example:

           <x-livewire _="alert" title="Warning">
                My alert message
                <x-slot name="footer">My custom footer </x-slot>
            </x-livewire>
            
            ....
    
            <div class="alert ...">
                {{ $slot }}
                <div class="alert-footer">
                    {{ $footer ?? 'Default footer content' }}
                </div>
            </div>
    
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1-beta(Aug 20, 2022)

  • 1.0.0-beta(Aug 2, 2022)

Owner
null
Render a Livewire component on a specific target in the DOM.

Livewire Portals Render a Livewire component on a specific target in the DOM. Install THIS PACKAGE IS STILL IN DEVELOPMENT, TO USE, PLEASE ADD THE FOL

Jeff Ochoa 20 Aug 11, 2022
Blade UI Kit is a set of renderless components to utilise in your Laravel Blade views

Blade UI Kit is a set of renderless components to utilise in your Laravel Blade views. In all essence, it's a collection of useful utilities, connecting the dots between different parts of the TALL stack. It was made for Blade, Laravel's powerful templating engine.

Blade UI Kit 1.2k Jan 5, 2023
Laravel-comments-livewire - Livewire components for the laravel-comments package

Associate comments and reactions with Eloquent models This package contains Livewire components to be used with the spatie/laravel-comments package. S

Spatie 15 Jan 18, 2022
Blade Snip allows you to use parts of a blade template multiple times. Basically partials, but inline.

Blade Snip Blade Snip allows you to use parts of a blade template multiple times. Basically partials, but inline: <div class="products"> @snip('pr

Jack Sleight 18 Dec 4, 2022
Laravel Livewire (TALL-stack) form generator with realtime validation, file uploads, array fields, blade form input components and more.

TALL-stack form generator Laravel Livewire, Tailwind forms with auto-generated views. Support Contributions Features This is not an admin panel genera

TinaH 622 Jan 2, 2023
A simple Content Moderation System for Laravel 5.* that allows you to Approve or Reject resources like posts, comments, users, etc.

Laravel Moderation A simple Moderation System for Laravel 5.* that allows you to Approve or Reject resources like posts, comments, users, etc. Keep yo

Alex Kyriakidis 509 Dec 30, 2022
Laravel package for giving admin-created accounts to users via 'set-password' email.

Invytr When making a website where users are created instead of registering themselves, you are faced with the challenge of safely giving users the ac

GlaivePro 64 Jul 17, 2022
A Pocketmine 4.0 Plugin which makes your server query = Current players + 1 Total Slots

The Better-Query Plugin This Plugin implements Better Query System **(i.e. 0/1 as player count)** the server total slots increases by 1 after a player

RealBJsingh 3 May 14, 2022
Emmet like Abbreviation to generate and wrap Laravel Blade Component with markup

Laravel Blade Emerald Emmet like Abbreviation to generate and wrap Laravel Blade Component with markup ?? Features Generate HTML in a Blade file via p

Aqua 32 Sep 6, 2022
Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.

About LivewireUI Spotlight LivewireUI Spotlight is a Livewire component that provides Spotlight/Alfred-like functionality to your Laravel application.

Livewire UI 792 Jan 3, 2023