ui-awesome/html-contracts

Contracts (interfaces) for the UI Awesome HTML ecosystem for PHP.

Installs: 227

Dependents: 2

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/ui-awesome/html-contracts

dev-main / 0.1.x-dev 2026-02-27 17:04 UTC

This package is auto-updated.

Last update: 2026-02-27 17:05:49 UTC


README

UI Awesome

Html contracts


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.1

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: attributes(), class(), getAttribute(), getAttributes(), removeAttribute(), setAttribute().

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

Quality code

PHPStan PHPStan Level Max Super-Linter StyleCI

Our social networks

Follow on X

License

License