northrook / inline-styles
Apply CSS-like selectors and merge declarations into HTML inline styles
dev-main
2026-07-10 19:07 UTC
Requires
- php: >=8.4
- ext-dom: *
- ext-libxml: *
Requires (Dev)
- northrook/php-cs: dev-main
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: @stable
- phpunit/phpunit: ^11.5
This package is not auto-updated.
Last update: 2026-07-11 16:48:57 UTC
README
[!WARNING] Early development.
The API and behaviour may change without notice.
Apply CSS-like selectors and merge declarations into HTML inline styles.
Requires PHP 8.4+.
Dependencies are ext-dom and ext-libxml.
Installation
composer require northrook/inline-styles
Quick start
use Northrook\InlineStyles;
use Northrook\InlineStyles\StripClasses;
$styles = new InlineStyles([
'.btn' => 'color: red; padding: 4px',
'#hero' => 'font-size: 24px',
], StripClasses::MATCHED);
$html = $styles
->rule('a[href^="https"]', 'text-decoration: none')
->apply($html);
Development
composer test
composer phpstan
License
BSD-3-Clause. See LICENSE.