PHPackages                             williams/bladestyler - 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. williams/bladestyler

ActiveLibrary[Templating &amp; Views](/categories/templating)

williams/bladestyler
====================

Adds functionality for maintaining consistent styling when using utility-first CSS frameworks, such as Tailwind, in Laravel Blade files.

v0.2.0(1y ago)021PHP

Since Sep 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/bwilliams-uk/BladeStyler)[ Packagist](https://packagist.org/packages/williams/bladestyler)[ RSS](/packages/williams-bladestyler/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

BladeStyler
===========

[](#bladestyler)

BladeStyler is a Laravel extension designed to help maintain consistent styling within views and components, particularly suited for utility-first CSS frameworks like Tailwind.

Installation &amp; Setup
------------------------

[](#installation--setup)

BladeStyler is installed using Composer. To install BladeStyler, run the following command in your Laravel project directory:

```
composer require williams/bladestyler
```

Directives
----------

[](#directives)

BladeStyler introduces five new blade directives:

- `@bs_set` - for defining reusable style class combinations.
- `@bs_class` - for applying class tags with the specified styles.
- `@bs_merge` - for merging style classes into blade component attributes.
- `@bs_string` - for printing the style classes as a string without any attribute handling.
- `@bs_clear` - for clearing definitions previously created with the `@bs_set` directive.

**Defining Styles**

Use `@bs_set` to define aliases for class style combinations:

```
@bs_set([
    'alert' => 'p-2 border',
    'success' => 'text-green-800 border-green-800 bg-green-200',
    'error' => 'text-red-800 border-red-800 bg-red-200'
])
```

**Applying styles**

You can apply these styles to HTML elements using the `@bs_class` directive:

```
Alert Message
```

This will produce the following output:

```
Alert Message
```

**Merging Attributes**

BladeStyler offers a short, elegant solution for merging style classes into a Blade component's attribute bag with the `@bs_merge` directive:

```
//components/button.blade.php

@props(['kind'=>'primary']) // Set default button as 'primary'

@bs_set([
    'primary' => 'text-white bg-blue-500 hover:bg-blue-800 rounded',
    'md' => 'p-2'
])

{{slot}}
```

Using the component:

```
Submit
```

This will produce:

```
Submit
```

**Obtaining classes as a string**

If the class list is required without class tags, use `@bs_string`:

```
Alert Message
```

**Clearing style definitions**

`@bs_clear` can be used to remove all or a specific definition:

```
@bs_set([
    'alert' => 'p-2 border',
    'success' => 'text-green-800 border-green-800 bg-green-200',
    'error' => 'text-red-800 border-red-800 bg-red-200'
])

{{--Remove a single definition--}}
@bs_clear('success')
@bs_string('alert success') {-- Output: p-2 border success --}

{{-- remove all definitions --}}
@bs_clear
@bs_string('alert success') {-- Output: alert success --}
```

Additional Features
-------------------

[](#additional-features)

**Conditional Styling**

The `@bs_class`, `@bs_merge` and `@bs_string` all support conditional styling, similar to Laravel's `@class` directive:

```
 !$isError,
    'error' => $isError
])>Alert Message
```

**Class Passthrough**

If a class is not registered using the `@bs_set` directive, it will be passed through directly to the generated HTML. This allows additional utility classes to be applied as required:

```
Alert Message
```

This will produce:

```
Alert Message
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~37 days

Total

2

Last Release

555d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3c99edde3f9f8c1bf87a077618cd96dad78a63e69e579965ad9dd17b4e078264?d=identicon)[bwilliams-uk](/maintainers/bwilliams-uk)

---

Top Contributors

[![bwilliams-uk](https://avatars.githubusercontent.com/u/38534904?v=4)](https://github.com/bwilliams-uk "bwilliams-uk (2 commits)")

### Embed Badge

![Health badge](/badges/williams-bladestyler/health.svg)

```
[![Health](https://phpackages.com/badges/williams-bladestyler/health.svg)](https://phpackages.com/packages/williams-bladestyler)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[symfony/ux-icons

Renders local and remote SVG icons in your Twig templates.

545.8M69](/packages/symfony-ux-icons)

PHPackages © 2026

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