# HasMicroData

> Provides an immutable API for microdata attributes.

[API reference](/docs/api/index.md) › [HTML Attribute](/docs/extensions/html-attribute/reference/index.md) › [Global](/docs/extensions/html-attribute/reference/global/index.md) › HasMicroData

| trait | `UIAwesome\Html\Attribute\Global\HasMicroData` |
| --- | --- |
| Source | [`src/Global/HasMicroData.php`](https://github.com/ui-awesome/html-attribute/blob/main/src/Global/HasMicroData.php#L17) |

Used by 1 type:

- [`UIAwesome\Html\Core\Element\BaseBlock`](/docs/extensions/html-core/reference/element/baseblock/index.md)

Provides an immutable API for microdata attributes.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`itemId()`](#method-itemId) | Sets the `itemid` attribute. | `HasMicroData` |
| [`itemProp()`](#method-itemProp) | Sets the `itemprop` attribute. | `HasMicroData` |
| [`itemRef()`](#method-itemRef) | Sets the `itemref` attribute. | `HasMicroData` |
| [`itemScope()`](#method-itemScope) | Sets the `itemscope` attribute. | `HasMicroData` |
| [`itemType()`](#method-itemType) | Sets the `itemtype` attribute. | `HasMicroData` |

## Method details

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

```php
public function itemId(string|Stringable|UnitEnum|null $value): static
```

Sets the `itemid` attribute.

**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` | Microdata item ID, or `null` to remove the attribute. |

**Returns**

`static`: New instance with the updated `itemid` attribute.

**See also**

- <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemid>

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

```php
public function itemProp(string|Stringable|UnitEnum|null $value): static
```

Sets the `itemprop` attribute.

**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` | Microdata item property, or `null` to remove the attribute. |

**Returns**

`static`: New instance with the updated `itemprop` attribute.

**See also**

- <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemprop>

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

```php
public function itemRef(string|Stringable|UnitEnum|null $value): static
```

Sets the `itemref` attribute.

**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` | Microdata item reference, or `null` to remove the attribute. |

**Returns**

`static`: New instance with the updated `itemref` attribute.

**See also**

- <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemref>

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

```php
public function itemScope(bool|null $value): static
```

Sets the `itemscope` attribute.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `bool\|null` | Whether to enable itemscope, or `null` to remove the attribute. |

**Returns**

`static`: New instance with the updated `itemscope` attribute.

**See also**

- <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemscope>

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

```php
public function itemType(string|Stringable|UnitEnum|null $value): static
```

Sets the `itemtype` attribute.

**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` | Microdata item type, or `null` to remove the attribute. |

**Returns**

`static`: New instance with the updated `itemtype` attribute.

**See also**

- <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemtype>