ui-awesome / html-attribute
Type-safe traits and backed enums for HTML attribute composition: global attributes, ARIA, data-*, events, and element-specific setters.
0.6.0
2026-04-30 15:36 UTC
Requires
- php: ^8.3
- ui-awesome/html-helper: ^0.7
- ui-awesome/html-mixin: ^0.5
Requires (Dev)
- infection/infection: ^0.32
- maglnet/composer-require-checker: ^4.1
- php-forge/coding-standard: ^0.1
- php-forge/support: ^0.3
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^12.5
This package is auto-updated.
Last update: 2026-05-01 01:54:32 UTC
README
Html Attribute
Features
A focused library for building and rendering structured HTML attributes
Type-safe helpers and value objects to compose complex attribute structures (classes, data-attributes, ARIA, etc.).
Installation
composer require ui-awesome/html-attribute:^0.6
Quick start
Compose reusable attribute APIs by combining the package traits with the immutable attribute mixin.
<?php declare(strict_types=1); namespace App; use UIAwesome\Html\Attribute\Global\{HasClass, HasData, HasId}; use UIAwesome\Html\Attribute\HasRel; use UIAwesome\Html\Attribute\Values\Rel; use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Mixin\HasAttributes; final class LinkAttributes { use HasAttributes; use HasClass; use HasData; use HasId; use HasRel; public function render(): string { return Attributes::render($this->getAttributes()); } } $attributes = (new LinkAttributes()) ->id('documentation') ->class('nav-link') ->class('is-active') ->rel(Rel::NOOPENER) ->addDataAttribute('tracking', 'docs'); echo '<a' . $attributes->render() . ' href="/docs">Documentation</a>';
Documentation
For detailed configuration options and advanced usage see:
- 🧪 Testing Guide