ui-awesome/html-attribute

Type-safe traits and backed enums for HTML attribute composition: global attributes, ARIA, data-*, events, and element-specific setters.

Package info

github.com/ui-awesome/html-attribute

pkg:composer/ui-awesome/html-attribute

Statistics

Installs: 34โ€‰411

Dependents: 5

Suggesters: 0

Stars: 1

Open Issues: 6

0.6.1 2026-05-01 13:59 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None


README

๐Ÿ‘ UI Awesome

Html Attribute


๐Ÿ‘ PHPUnit
๐Ÿ‘ Mutation Testing
๐Ÿ‘ PHPStan

Features

๐Ÿ‘ Feature Overview

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:

Package information

๐Ÿ‘ PHP
๐Ÿ‘ Latest Stable Version
๐Ÿ‘ Total Downloads

Quality code

๐Ÿ‘ Codecov
๐Ÿ‘ PHPStan Level Max
๐Ÿ‘ Super-Linter
๐Ÿ‘ StyleCI

Our social networks

๐Ÿ‘ Follow on X
๐Ÿ‘ Follow on Facebook

License

๐Ÿ‘ License