# HasSuffixCollection

> Provides an immutable API for managing suffix element and its attributes.

[API reference](/docs/api/index.md) › [HTML Mixin](/docs/extensions/html-mixin/reference/index.md) › HasSuffixCollection

| trait | `UIAwesome\Html\Mixin\HasSuffixCollection` |
| --- | --- |
| Source | [`src/HasSuffixCollection.php`](https://github.com/ui-awesome/html-mixin/blob/main/src/HasSuffixCollection.php#L16) |

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 an immutable API for managing suffix element and its attributes.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-suffix"></span>`$suffix` protected | `string` | Suffix content string assigned to the element. Default: `''`. | `HasSuffixCollection` |
| <span id="property-suffixAttributes"></span>`$suffixAttributes` protected | `array` | HTML attributes array for the suffix element. Default: `[]`. | `HasSuffixCollection` |
| <span id="property-suffixTag"></span>`$suffixTag` protected | `false\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php) | Tag name for the suffix element, or `false` to disable. Default: `false`. | `HasSuffixCollection` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`getSuffix()`](#method-getSuffix) | Returns the suffix content string assigned to the element. | `HasSuffixCollection` |
| [`getSuffixAttribute()`](#method-getSuffixAttribute) | Returns the value of a single HTML attribute for the suffix element attributes. | `HasSuffixCollection` |
| [`getSuffixAttributes()`](#method-getSuffixAttributes) | Returns the `array` of HTML attributes for the suffix element. | `HasSuffixCollection` |
| [`getSuffixTag()`](#method-getSuffixTag) | Returns the tag name for the suffix element. | `HasSuffixCollection` |
| [`suffix()`](#method-suffix) | Sets the suffix content string for the element. | `HasSuffixCollection` |
| [`suffixAttributes()`](#method-suffixAttributes) | Sets the HTML attributes for the suffix element. | `HasSuffixCollection` |
| [`suffixClass()`](#method-suffixClass) | Adds a CSS class to the suffix element attributes. | `HasSuffixCollection` |
| [`suffixRemoveAttribute()`](#method-suffixRemoveAttribute) | Removes a specific HTML attribute from the suffix element. | `HasSuffixCollection` |
| [`suffixSetAttribute()`](#method-suffixSetAttribute) | Sets a single HTML attribute for the suffix element. | `HasSuffixCollection` |
| [`suffixTag()`](#method-suffixTag) | Sets the tag type for the suffix element. | `HasSuffixCollection` |

## Method details

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

```php
public function getSuffix(): string
```

Returns the suffix content string assigned to the element.

**Returns**

`string`: Suffix content string assigned to the element.

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

```php
public function getSuffixAttribute(string|UnitEnum $key, mixed $default = null, string $prefix = ''): mixed
```

Returns the value of a single HTML attribute for the suffix element attributes.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$key` | `string\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php) | Attribute name. |
| `$default` | `mixed` | Default value when the attribute is missing. |
| `$prefix` | `string` | Prefix to ensure (for example, `aria-`, `data-`, `on`). |

**Returns**

`mixed`: Attribute value or default.

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

```php
public function getSuffixAttributes(): array
```

Returns the `array` of HTML attributes for the suffix element.

**Returns**

`array`: Attributes `array` assigned to the suffix element.

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

```php
public function getSuffixTag(): false|UnitEnum
```

Returns the tag name for the suffix element.

**Returns**

`false|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php): Tag name for the suffix element, or `false` to disable.

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

```php
public function suffix(string|Stringable ...$values): static
```

Sets the suffix content string for the element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `...$values` | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php) | Suffix content to set for the element. |

**Returns**

`static`: New instance with the updated `suffix` value.

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

```php
public function suffixAttributes(array $values, string $prefix = ''): static
```

Sets the HTML attributes for the suffix element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$values` | `array` | Associative array of attribute keys and values. |
| `$prefix` | `string` | Prefix to ensure (for example, `aria-`, `data-`, `on`). |

**Returns**

`static`: New instance with the updated `suffixAttributes` value.

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

```php
public function suffixClass(string|Stringable|UnitEnum|null $value, bool $override = false): static
```

Adds a CSS class to the suffix element attributes.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php)`\|null` | CSS class name to add. |
| `$override` | `bool` | Whether to override existing class value. |

**Returns**

`static`: New instance with the updated `suffixAttributes` value.

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

```php
public function suffixRemoveAttribute(string|UnitEnum $key, string $prefix = ''): static
```

Removes a specific HTML attribute from the suffix element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$key` | `string\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php) | Attribute name to remove. |
| `$prefix` | `string` | Prefix to ensure (for example, `aria-`, `data-`, `on`). |

**Returns**

`static`: New instance without the specified suffix attribute.

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

```php
public function suffixSetAttribute(string|UnitEnum $key, mixed $value, string $prefix = ''): static
```

Sets a single HTML attribute for the suffix element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$key` | `string\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php) | Attribute name. |
| `$value` | `mixed` | Attribute value. |
| `$prefix` | `string` | Prefix to ensure (for example, `aria-`, `data-`, `on`). |

**Returns**

`static`: New instance with the updated `suffixAttributes` value.

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

```php
public function suffixTag(false|UnitEnum $value = false): static
```

Sets the tag type for the suffix element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `false\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php) | Tag name for the suffix element, or `false` to disable. |

**Returns**

`static`: New instance with the updated `suffixTag` value.