northrook / inline-styles
Apply CSS-like selectors and merge declarations into HTML inline styles
dev-main
2026-08-07 12:37 UTC
Requires
- php: >=8.5
- ext-dom: *
- ext-libxml: *
Requires (Dev)
- northrook/php-cs: dev-main
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^13
This package is not auto-updated.
Last update: 2026-08-08 17:06:30 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.5+.
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 check
composer fmt
License
BSD-3-Clause. See LICENSE.