Download the PHP package williams/bladestyler without Composer
On this page you can find all versions of the php package williams/bladestyler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download williams/bladestyler
More information about williams/bladestyler
Files in williams/bladestyler
Package bladestyler
Short Description Adds functionality for maintaining consistent styling when using utility-first CSS frameworks, such as Tailwind, in Laravel Blade files.
License
Informations about the package 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 & Setup
BladeStyler is installed using Composer. To install BladeStyler, run the following command in your Laravel project directory:
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:
Applying styles
You can apply these styles to HTML elements using the @bs_class
directive:
This will produce the following output:
Merging Attributes
BladeStyler offers a short, elegant solution for merging style classes into a Blade component's attribute bag with the @bs_merge
directive:
Using the component:
This will produce:
Obtaining classes as a string
If the class list is required without class tags, use @bs_string
:
Clearing style definitions
@bs_clear
can be used to remove all or a specific definition:
Additional Features
Conditional Styling
The @bs_class
, @bs_merge
and @bs_string
all support conditional styling, similar to Laravel's @class
directive:
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:
This will produce: