LaravelPackages.net
Acme Inc.
Toggle sidebar
jey/livewire-styleable

A package for defining scoped styles in Livewire components (Scss support)

33
5
v1.0
About jey/livewire-styleable

jey/livewire-styleable is a Laravel package for a package for defining scoped styles in livewire components (scss support). It currently has 5 GitHub stars and 33 downloads on Packagist (latest version v1.0). Install it with composer require jey/livewire-styleable. Discover more Laravel packages by jey or browse all Laravel packages to compare alternatives.

Last updated

LivewireStyleable

Installing:

composer require jey/livewire-styleable

Using:

In Component class:

<?php namespace App\View\Component; use App\Models\Post; use Jey\LivewireStyleable\HasStyle; use Livewire\Component; class LatestPosts extends Component { use HasStyle; public function render() { return view('components.latest-posts', [ 'posts' => Post::published() ->latest() ->take(3) ->get(), ]); } }

In Blade template (latest-posts.blade.php):

<div>
    <div class="row">
        @foreach($posts as $post)
            <div class="col-xs-1 col-md-3 col-lg-4 mb-3">
                <div class="card">
                    <img src="{{ $post->image_url }}" alt="" class="card-img">
                    <div class="card-body" style="">
                        {{ $post->description }}
                    </div>
                </div>
            </div>
        @endforeach
    </div>
</div>
<style scoped lang="scss">
    .card {
        border-radius: 1rem;
        overflow: hidden;
        $card-color: red;
        .card-body {
            color: $card-color;
        }
    }
</style>

Module import support (Non-Webpack packages)

<style scoped lang="scss">
    @module('LatestPosts')
</style>

Star History Chart