keruyphp / fluent-bulma
Flexible fluent PHP DSL for Bulma.
v1.0.0
2026-05-06 19:18 UTC
Requires
- php: ^8.3
- keruyphp/fluent-html: *
README
Simple fluent PHP DSL for applying Bulma classes to fluent-html elements.
Installation
composer require keruyphp/fluent-bulma
Minimal setup
<?php declare(strict_types=1); require __DIR__ . '/vendor/autoload.php'; use KeruyPHP\FluentBulma\Bulma; use KeruyPHP\FluentHtml\Html; use KeruyPHP\FluentHtml\HtmlElement; HtmlElement::extend('bulma', fn(HtmlElement $el) => new Bulma($el)); echo Html::button('Save') ->bulma()->button()->isPrimary()->isRounded();
Main Bulma elements
Start with a normal fluent-html element, then call bulma().
Title
echo Html::h1('Dashboard') ->bulma()->title()->is_1();
Button
echo Html::button('Save') ->bulma()->button()->isPrimary()->isRounded();
Notification
echo Html::div('Profile updated') ->bulma()->notification()->isSuccess();
Columns
echo Html::div(function () { Html::div('Left column')->bulma()->column(); Html::div('Right column')->bulma()->column(); }));
Input
echo Html::input(['type' => 'text']) ->bulma()->input()->isRounded();
Tag
echo Html::span('New') ->bulma()->tag()->isInfo()->isRounded();
Helpers
Bulma helpers are available through helpers().
echo Html::span('Info text') ->bulma()->helpers()->textColor()->hasTextInfo();
Returning to HtmlElement
Bulma methods return helper objects. Call end() to get the original HtmlElement back.
echo Html::button('Open') ->bulma()->button()->isPrimary()->end() ->prop('type', 'button') ->class('custom-button');
Notes
fluent-bulmaworks on top offluent-html.- You can still use normal
HtmlElementmethods likeclass(),prop(),attrs()andpretty(). - Many Bulma modifier methods are virtual and are converted from camelCase to kebab-case classes automatically.