Search by

ui-awesome / html-contracts

terabytesoftw

Shared interfaces for the UI Awesome HTML ecosystem: rendering, attribute management, element typing, and form controls.

Package info

github.com/ui-awesome/html-contracts

pkg:composer/ui-awesome/html-contracts

Statistics

Installs: 21 693

Dependents: 5

Suggesters: 0

Stars: 2

Open Issues: 0

0.2.2 2026-09-09 09:29 UTC

This package is auto-updated.

Last update: 2026-09-09 09:31:55 UTC


README

UI Awesome

HTML Contracts for PHP


PHPStan Security

Contracts (interfaces) for the UI Awesome HTML ecosystem for PHP
Provides shared interfaces for rendering, attribute management, and form control typing across HTML packages.

Installation

composer require ui-awesome/html-contracts:^0.2

Interfaces

RenderableInterface

Core contract for any object that can be rendered as an HTML string. Extends Stringable.

<?php

declare(strict_types=1);

use UIAwesome\Html\Contracts\RenderableInterface;

final class MyTag implements RenderableInterface
{
    public function __toString(): string
    {
        return $this->render();
    }

    public function render(): string
    {
        return '<div>Hello</div>';
    }
}

AttributesInterface

Contract for objects that manage HTML attributes with an immutable API.

Methods: addAttribute(), attributes(), class(), getAttribute(), getAttributes(), and removeAttribute().

ContentInterface

Contract for immutable encoded element content. content(string|Stringable|UnitEnum ...$values) normalizes enum values before HTML encoding; getContent() returns accumulated content, and html(string|Stringable|UnitEnum ...$values) normalizes enum values and appends trusted raw HTML without encoding or sanitizing. Backed enums use their value (including integer zero); pure enums use their name.

Existing callers remain compatible. Implementations and overrides retaining the old narrower signature must be updated; see the upgrade guide for details and coordinated Composer requirements.

FormControlInterface

Composed interface extending both RenderableInterface and AttributesInterface. Use this to type form control elements (inputs, selects, textareas, etc.) that need both rendering and attribute management.

<?php

declare(strict_types=1);

use UIAwesome\Html\Contracts\Form\FormControlInterface;

function renderField(FormControlInterface $control): string
{
    return $control->class('form-control')->render();
}

Documentation

For detailed configuration options and advanced usage.

Package information

PHP Latest Stable Version Total Downloads

Project status

PHPStan Level Max Quality StyleCI

Our social networks

Follow on X Follow on Facebook

License

License