# HasElementBuilder

> Provides template-driven composition of the prefix, tag, and suffix segments of an element.

[API reference](/docs/api/index.md) › [HTML Core](/docs/extensions/html-core/reference/index.md) › [Element](/docs/extensions/html-core/reference/element/index.md) › [Concern](/docs/extensions/html-core/reference/element/concern/index.md) › HasElementBuilder

| trait | `UIAwesome\Html\Core\Element\Concern\HasElementBuilder` |
| --- | --- |
| Source | [`src/Element/Concern/HasElementBuilder.php`](https://github.com/ui-awesome/html-core/blob/main/src/Element/Concern/HasElementBuilder.php#L19) |

Used by 2 types:

- [`UIAwesome\Html\Core\Element\BaseInline`](/docs/extensions/html-core/reference/element/baseinline/index.md)
- [`UIAwesome\Html\Core\Element\BaseInput`](/docs/extensions/html-core/reference/element/baseinput/index.md)

Provides template-driven composition of the prefix, tag, and suffix segments of an element.

Each segment is rendered with the renderer matching its tag kind, and the `{prefix}`, `{tag}`, and `{suffix}` tokens
are then replaced in the configured template.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`buildElement()`](#method-buildElement) protected | Builds element output from content and template tokens. | `HasElementBuilder` |

## Method details

### buildElement() <span id="method-buildElement"></span>

```php
protected function buildElement(string|Stringable $content = '', array $tokenValues = []): string
```

Builds element output from content and template tokens.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$content` | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php) | Content to be rendered inside the tag. Void tags, such as `<input>`, render no inner content; use attributes such as `value` instead. |
| `$tokenValues` | `array` | Additional token values for template rendering. |

**Returns**

`string`: Rendered HTML for the element.