# BaseSvg

> Base class for constructing <svg> elements.

[API reference](/docs/api/index.md) › [HTML SVG](/docs/extensions/html-svg/reference/index.md) › [Base](/docs/extensions/html-svg/reference/base/index.md) › BaseSvg

| abstract class | `UIAwesome\Html\Svg\Base\BaseSvg` |
| --- | --- |
| Extends | [`UIAwesome\Html\Core\Element\BaseBlock`](/docs/extensions/html-core/reference/element/baseblock/index.md) » [`UIAwesome\Html\Core\Base\BaseTag`](/docs/extensions/html-core/reference/base/basetag/index.md) |
| Implements | [`Stringable`](https://www.php.net/manual/en/class.stringable.php), [`UIAwesome\Html\Contracts\Attribute\AttributesInterface`](/docs/extensions/html-contracts/reference/attribute/attributesinterface/index.md), [`UIAwesome\Html\Contracts\Element\BlockInterface`](/docs/extensions/html-contracts/reference/element/blockinterface/index.md), [`UIAwesome\Html\Contracts\Element\ClearableContentInterface`](/docs/extensions/html-contracts/reference/element/clearablecontentinterface/index.md), [`UIAwesome\Html\Contracts\RenderableInterface`](/docs/extensions/html-contracts/reference/renderableinterface/index.md) |
| Uses traits | [`UIAwesome\Html\Attribute\Global\CanBeAutofocus`](/docs/extensions/html-attribute/reference/global/canbeautofocus/index.md), [`UIAwesome\Html\Attribute\Global\CanBeHidden`](/docs/extensions/html-attribute/reference/global/canbehidden/index.md), [`UIAwesome\Html\Attribute\Global\HasAccesskey`](/docs/extensions/html-attribute/reference/global/hasaccesskey/index.md), [`UIAwesome\Html\Attribute\Global\HasAria`](/docs/extensions/html-attribute/reference/global/hasaria/index.md), [`UIAwesome\Html\Mixin\HasAttributes`](/docs/extensions/html-mixin/reference/hasattributes/index.md), [`UIAwesome\Html\Attribute\Global\HasClass`](/docs/extensions/html-attribute/reference/global/hasclass/index.md), [`UIAwesome\Html\Mixin\HasContent`](/docs/extensions/html-mixin/reference/hascontent/index.md), [`UIAwesome\Html\Attribute\Global\HasContentEditable`](/docs/extensions/html-attribute/reference/global/hascontenteditable/index.md), [`UIAwesome\Html\Attribute\Global\HasData`](/docs/extensions/html-attribute/reference/global/hasdata/index.md), [`UIAwesome\Html\Attribute\Global\HasDir`](/docs/extensions/html-attribute/reference/global/hasdir/index.md), [`UIAwesome\Html\Attribute\Global\HasDraggable`](/docs/extensions/html-attribute/reference/global/hasdraggable/index.md), [`UIAwesome\Html\Attribute\Global\HasEvents`](/docs/extensions/html-attribute/reference/global/hasevents/index.md), [`UIAwesome\Html\Attribute\Global\HasId`](/docs/extensions/html-attribute/reference/global/hasid/index.md), [`UIAwesome\Html\Attribute\Global\HasLang`](/docs/extensions/html-attribute/reference/global/haslang/index.md), [`UIAwesome\Html\Attribute\Global\HasMicroData`](/docs/extensions/html-attribute/reference/global/hasmicrodata/index.md), [`UIAwesome\Html\Attribute\Global\HasRole`](/docs/extensions/html-attribute/reference/global/hasrole/index.md), [`UIAwesome\Html\Attribute\Global\HasSpellcheck`](/docs/extensions/html-attribute/reference/global/hasspellcheck/index.md), [`UIAwesome\Html\Attribute\Global\HasStyle`](/docs/extensions/html-attribute/reference/global/hasstyle/index.md), [`UIAwesome\Html\Attribute\Global\HasTabindex`](/docs/extensions/html-attribute/reference/global/hastabindex/index.md), [`UIAwesome\Html\Attribute\Global\HasTitle`](/docs/extensions/html-attribute/reference/global/hastitle/index.md), [`UIAwesome\Html\Attribute\Global\HasTranslate`](/docs/extensions/html-attribute/reference/global/hastranslate/index.md), [`UIAwesome\Html\Core\Event\HasAfterRun`](/docs/extensions/html-core/reference/event/hasafterrun/index.md), [`UIAwesome\Html\Core\Event\HasBeforeRun`](/docs/extensions/html-core/reference/event/hasbeforerun/index.md) |
| Source | [`src/Base/BaseSvg.php`](https://github.com/ui-awesome/html-svg/blob/main/src/Base/BaseSvg.php#L36) |

1 subclass:

- [`UIAwesome\Html\Svg\Svg`](/docs/extensions/html-svg/reference/svg/index.md)

Base class for constructing `<svg>` elements.

Provides the shared implementation for SVG container rendering, including attribute handling, content management, and
immutable updates.

Intended for SVG classes that need SVG container behavior with file-backed rendering and attribute processing.

See also: <https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg> ([`BaseBlock`](/docs/extensions/html-core/reference/element/baseblock/index.md) for the base block-level implementation. [`SvgAttribute`](/docs/extensions/html-svg/reference/values/svgattribute/index.md) for supported SVG attributes.).

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-attributes"></span>[`$attributes`](/docs/extensions/html-mixin/reference/hasattributes/index.md#property-attributes) protected | `mixed[]` | HTML attributes array used by the implementing class. Default: `[]`. | [`UIAwesome\Html\Mixin\HasAttributes`](/docs/extensions/html-mixin/reference/hasattributes/index.md) |
| <span id="property-content"></span>[`$content`](/docs/extensions/html-mixin/reference/hascontent/index.md#property-content) protected | `string` | Content string assigned to the element. Default: `''`. | [`UIAwesome\Html\Mixin\HasContent`](/docs/extensions/html-mixin/reference/hascontent/index.md) |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-__construct"></span>[`__construct()`](/docs/extensions/html-core/reference/base/basetag/index.md#method-__construct) final | Initializes a new tag instance. | [`UIAwesome\Html\Core\Base\BaseTag`](/docs/extensions/html-core/reference/base/basetag/index.md) |
| <span id="method-__toString"></span>[`__toString()`](/docs/extensions/html-core/reference/base/basetag/index.md#method-__toString) | Returns the rendered tag string. | [`UIAwesome\Html\Core\Base\BaseTag`](/docs/extensions/html-core/reference/base/basetag/index.md) |
| <span id="method-accesskey"></span>[`accesskey()`](/docs/extensions/html-attribute/reference/global/hasaccesskey/index.md#method-accesskey) | Sets the `accesskey` attribute. | [`UIAwesome\Html\Attribute\Global\HasAccesskey`](/docs/extensions/html-attribute/reference/global/hasaccesskey/index.md) |
| <span id="method-addAriaAttribute"></span>[`addAriaAttribute()`](/docs/extensions/html-attribute/reference/global/hasaria/index.md#method-addAriaAttribute) | Sets an `aria-*` attribute. | [`UIAwesome\Html\Attribute\Global\HasAria`](/docs/extensions/html-attribute/reference/global/hasaria/index.md) |
| <span id="method-addAttribute"></span>[`addAttribute()`](/docs/extensions/html-mixin/reference/hasattributes/index.md#method-addAttribute) | Adds or updates a single HTML attribute for the element. | [`UIAwesome\Html\Mixin\HasAttributes`](/docs/extensions/html-mixin/reference/hasattributes/index.md) |
| <span id="method-addDataAttribute"></span>[`addDataAttribute()`](/docs/extensions/html-attribute/reference/global/hasdata/index.md#method-addDataAttribute) | Sets a `data-*` attribute. | [`UIAwesome\Html\Attribute\Global\HasData`](/docs/extensions/html-attribute/reference/global/hasdata/index.md) |
| <span id="method-addEvent"></span>[`addEvent()`](/docs/extensions/html-attribute/reference/global/hasevents/index.md#method-addEvent) | Sets an `on*` event attribute. | [`UIAwesome\Html\Attribute\Global\HasEvents`](/docs/extensions/html-attribute/reference/global/hasevents/index.md) |
| <span id="method-ariaAttributes"></span>[`ariaAttributes()`](/docs/extensions/html-attribute/reference/global/hasaria/index.md#method-ariaAttributes) | Sets multiple `aria-*` attributes. | [`UIAwesome\Html\Attribute\Global\HasAria`](/docs/extensions/html-attribute/reference/global/hasaria/index.md) |
| <span id="method-attributes"></span>[`attributes()`](/docs/extensions/html-mixin/reference/hasattributes/index.md#method-attributes) | Adds or updates multiple HTML attributes for the element. | [`UIAwesome\Html\Mixin\HasAttributes`](/docs/extensions/html-mixin/reference/hasattributes/index.md) |
| <span id="method-autofocus"></span>[`autofocus()`](/docs/extensions/html-attribute/reference/global/canbeautofocus/index.md#method-autofocus) | Sets the `autofocus` attribute. | [`UIAwesome\Html\Attribute\Global\CanBeAutofocus`](/docs/extensions/html-attribute/reference/global/canbeautofocus/index.md) |
| <span id="method-begin"></span>[`begin()`](/docs/extensions/html-core/reference/element/baseblock/index.md#method-begin) final | Starts begin/end rendering for this instance. | [`UIAwesome\Html\Core\Element\BaseBlock`](/docs/extensions/html-core/reference/element/baseblock/index.md) |
| <span id="method-class"></span>[`class()`](/docs/extensions/html-attribute/reference/global/hasclass/index.md#method-class) | Sets the `class` attribute. | [`UIAwesome\Html\Attribute\Global\HasClass`](/docs/extensions/html-attribute/reference/global/hasclass/index.md) |
| <span id="method-clearContent"></span>[`clearContent()`](/docs/extensions/html-mixin/reference/hascontent/index.md#method-clearContent) | Clears encoded and raw content without changing other component state. | [`UIAwesome\Html\Mixin\HasContent`](/docs/extensions/html-mixin/reference/hascontent/index.md) |
| <span id="method-config"></span>[`config()`](/docs/extensions/html-core/reference/base/basetag/index.md#method-config) | Applies application-scoped config recipes to this tag. | [`UIAwesome\Html\Core\Base\BaseTag`](/docs/extensions/html-core/reference/base/basetag/index.md) |
| <span id="method-content"></span>[`content()`](/docs/extensions/html-mixin/reference/hascontent/index.md#method-content) | Appends encoded content. | [`UIAwesome\Html\Mixin\HasContent`](/docs/extensions/html-mixin/reference/hascontent/index.md) |
| <span id="method-contentEditable"></span>[`contentEditable()`](/docs/extensions/html-attribute/reference/global/hascontenteditable/index.md#method-contentEditable) | Sets the `contenteditable` attribute. | [`UIAwesome\Html\Attribute\Global\HasContentEditable`](/docs/extensions/html-attribute/reference/global/hascontenteditable/index.md) |
| <span id="method-dataAttributes"></span>[`dataAttributes()`](/docs/extensions/html-attribute/reference/global/hasdata/index.md#method-dataAttributes) | Sets multiple `data-*` attributes. | [`UIAwesome\Html\Attribute\Global\HasData`](/docs/extensions/html-attribute/reference/global/hasdata/index.md) |
| <span id="method-dir"></span>[`dir()`](/docs/extensions/html-attribute/reference/global/hasdir/index.md#method-dir) | Sets the `dir` attribute. | [`UIAwesome\Html\Attribute\Global\HasDir`](/docs/extensions/html-attribute/reference/global/hasdir/index.md) |
| <span id="method-draggable"></span>[`draggable()`](/docs/extensions/html-attribute/reference/global/hasdraggable/index.md#method-draggable) | Sets the `draggable` attribute. | [`UIAwesome\Html\Attribute\Global\HasDraggable`](/docs/extensions/html-attribute/reference/global/hasdraggable/index.md) |
| <span id="method-end"></span>[`end()`](/docs/extensions/html-core/reference/element/baseblock/index.md#method-end) static final | Ends the most recent begin/end rendering block for the current class. | [`UIAwesome\Html\Core\Element\BaseBlock`](/docs/extensions/html-core/reference/element/baseblock/index.md) |
| <span id="method-events"></span>[`events()`](/docs/extensions/html-attribute/reference/global/hasevents/index.md#method-events) | Sets multiple `on*` event attributes. | [`UIAwesome\Html\Attribute\Global\HasEvents`](/docs/extensions/html-attribute/reference/global/hasevents/index.md) |
| [`filePath()`](#method-filePath) | Sets the file path for the SVG file to be rendered. | `BaseSvg` |
| [`fill()`](#method-fill) | Sets the SVG `fill` attribute for the element. | `BaseSvg` |
| [`fillOpacity()`](#method-fillOpacity) | Sets SVG `fill-opacity` attribute for the element. | `BaseSvg` |
| [`fillRule()`](#method-fillRule) | Sets SVG `fill-rule` attribute for the element. | `BaseSvg` |
| <span id="method-getAttribute"></span>[`getAttribute()`](/docs/extensions/html-mixin/reference/hasattributes/index.md#method-getAttribute) | Returns the value of a single HTML attribute. | [`UIAwesome\Html\Mixin\HasAttributes`](/docs/extensions/html-mixin/reference/hasattributes/index.md) |
| [`getAttributes()`](#method-getAttributes) | Overrides the attribute retrieval to filter out the `title` attribute. | `BaseSvg` |
| [`getContent()`](#method-getContent) | Retrieves the content of the SVG element, injecting a `<title>` element when defined. | `BaseSvg` |
| [`height()`](#method-height) | Sets the `height` attribute. | `BaseSvg` |
| <span id="method-hidden"></span>[`hidden()`](/docs/extensions/html-attribute/reference/global/canbehidden/index.md#method-hidden) | Sets the `hidden` attribute. | [`UIAwesome\Html\Attribute\Global\CanBeHidden`](/docs/extensions/html-attribute/reference/global/canbehidden/index.md) |
| <span id="method-html"></span>[`html()`](/docs/extensions/html-mixin/reference/hascontent/index.md#method-html) | Appends trusted raw HTML content without encoding or sanitizing it. | [`UIAwesome\Html\Mixin\HasContent`](/docs/extensions/html-mixin/reference/hascontent/index.md) |
| <span id="method-id"></span>[`id()`](/docs/extensions/html-attribute/reference/global/hasid/index.md#method-id) | Sets the `id` attribute. | [`UIAwesome\Html\Attribute\Global\HasId`](/docs/extensions/html-attribute/reference/global/hasid/index.md) |
| <span id="method-itemId"></span>[`itemId()`](/docs/extensions/html-attribute/reference/global/hasmicrodata/index.md#method-itemId) | Sets the `itemid` attribute. | [`UIAwesome\Html\Attribute\Global\HasMicroData`](/docs/extensions/html-attribute/reference/global/hasmicrodata/index.md) |
| <span id="method-itemProp"></span>[`itemProp()`](/docs/extensions/html-attribute/reference/global/hasmicrodata/index.md#method-itemProp) | Sets the `itemprop` attribute. | [`UIAwesome\Html\Attribute\Global\HasMicroData`](/docs/extensions/html-attribute/reference/global/hasmicrodata/index.md) |
| <span id="method-itemRef"></span>[`itemRef()`](/docs/extensions/html-attribute/reference/global/hasmicrodata/index.md#method-itemRef) | Sets the `itemref` attribute. | [`UIAwesome\Html\Attribute\Global\HasMicroData`](/docs/extensions/html-attribute/reference/global/hasmicrodata/index.md) |
| <span id="method-itemScope"></span>[`itemScope()`](/docs/extensions/html-attribute/reference/global/hasmicrodata/index.md#method-itemScope) | Sets the `itemscope` attribute. | [`UIAwesome\Html\Attribute\Global\HasMicroData`](/docs/extensions/html-attribute/reference/global/hasmicrodata/index.md) |
| <span id="method-itemType"></span>[`itemType()`](/docs/extensions/html-attribute/reference/global/hasmicrodata/index.md#method-itemType) | Sets the `itemtype` attribute. | [`UIAwesome\Html\Attribute\Global\HasMicroData`](/docs/extensions/html-attribute/reference/global/hasmicrodata/index.md) |
| <span id="method-lang"></span>[`lang()`](/docs/extensions/html-attribute/reference/global/haslang/index.md#method-lang) | Sets the `lang` attribute. | [`UIAwesome\Html\Attribute\Global\HasLang`](/docs/extensions/html-attribute/reference/global/haslang/index.md) |
| [`opacity()`](#method-opacity) | Sets the SVG `opacity` attribute for the element. | `BaseSvg` |
| [`preserveAspectRatio()`](#method-preserveAspectRatio) | Sets the SVG `preserveAspectRatio` attribute for the element. | `BaseSvg` |
| <span id="method-removeAriaAttribute"></span>[`removeAriaAttribute()`](/docs/extensions/html-attribute/reference/global/hasaria/index.md#method-removeAriaAttribute) | Removes an `aria-*` attribute. | [`UIAwesome\Html\Attribute\Global\HasAria`](/docs/extensions/html-attribute/reference/global/hasaria/index.md) |
| <span id="method-removeAttribute"></span>[`removeAttribute()`](/docs/extensions/html-mixin/reference/hasattributes/index.md#method-removeAttribute) | Removes a specific HTML attribute from the element. | [`UIAwesome\Html\Mixin\HasAttributes`](/docs/extensions/html-mixin/reference/hasattributes/index.md) |
| <span id="method-removeDataAttribute"></span>[`removeDataAttribute()`](/docs/extensions/html-attribute/reference/global/hasdata/index.md#method-removeDataAttribute) | Removes a `data-*` attribute. | [`UIAwesome\Html\Attribute\Global\HasData`](/docs/extensions/html-attribute/reference/global/hasdata/index.md) |
| <span id="method-removeEvent"></span>[`removeEvent()`](/docs/extensions/html-attribute/reference/global/hasevents/index.md#method-removeEvent) | Removes an `on*` event attribute. | [`UIAwesome\Html\Attribute\Global\HasEvents`](/docs/extensions/html-attribute/reference/global/hasevents/index.md) |
| <span id="method-render"></span>[`render()`](/docs/extensions/html-core/reference/base/basetag/index.md#method-render) final | Renders the tag with lifecycle hooks. | [`UIAwesome\Html\Core\Base\BaseTag`](/docs/extensions/html-core/reference/base/basetag/index.md) |
| <span id="method-replaceAttributes"></span>[`replaceAttributes()`](/docs/extensions/html-mixin/reference/hasattributes/index.md#method-replaceAttributes) | Replaces all HTML attributes for the element. | [`UIAwesome\Html\Mixin\HasAttributes`](/docs/extensions/html-mixin/reference/hasattributes/index.md) |
| <span id="method-role"></span>[`role()`](/docs/extensions/html-attribute/reference/global/hasrole/index.md#method-role) | Sets the `role` attribute. | [`UIAwesome\Html\Attribute\Global\HasRole`](/docs/extensions/html-attribute/reference/global/hasrole/index.md) |
| <span id="method-spellcheck"></span>[`spellcheck()`](/docs/extensions/html-attribute/reference/global/hasspellcheck/index.md#method-spellcheck) | Sets the `spellcheck` attribute. | [`UIAwesome\Html\Attribute\Global\HasSpellcheck`](/docs/extensions/html-attribute/reference/global/hasspellcheck/index.md) |
| [`stroke()`](#method-stroke) | Sets the SVG `stroke` attribute for the element. | `BaseSvg` |
| [`strokeDashArray()`](#method-strokeDashArray) | Sets the SVG `stroke-dasharray` attribute for the element. | `BaseSvg` |
| [`strokeLineCap()`](#method-strokeLineCap) | Sets the SVG `stroke-linecap` attribute for the element. | `BaseSvg` |
| [`strokeLineJoin()`](#method-strokeLineJoin) | Sets the SVG `stroke-linejoin` attribute for the element. | `BaseSvg` |
| [`strokeMiterlimit()`](#method-strokeMiterlimit) | Sets SVG `stroke-miterlimit` attribute for the element. | `BaseSvg` |
| [`strokeOpacity()`](#method-strokeOpacity) | Sets SVG `stroke-opacity` attribute for the element. | `BaseSvg` |
| [`strokeWidth()`](#method-strokeWidth) | Sets the SVG `stroke-width` attribute for the element. | `BaseSvg` |
| <span id="method-style"></span>[`style()`](/docs/extensions/html-attribute/reference/global/hasstyle/index.md#method-style) | Sets the `style` attribute. | [`UIAwesome\Html\Attribute\Global\HasStyle`](/docs/extensions/html-attribute/reference/global/hasstyle/index.md) |
| <span id="method-tabIndex"></span>[`tabIndex()`](/docs/extensions/html-attribute/reference/global/hastabindex/index.md#method-tabIndex) | Sets the `tabindex` attribute. | [`UIAwesome\Html\Attribute\Global\HasTabindex`](/docs/extensions/html-attribute/reference/global/hastabindex/index.md) |
| <span id="method-tag"></span>[`tag()`](/docs/extensions/html-core/reference/base/basetag/index.md#method-tag) static | Creates and configures a new tag instance. | [`UIAwesome\Html\Core\Base\BaseTag`](/docs/extensions/html-core/reference/base/basetag/index.md) |
| <span id="method-title"></span>[`title()`](/docs/extensions/html-attribute/reference/global/hastitle/index.md#method-title) | Sets the `title` attribute. | [`UIAwesome\Html\Attribute\Global\HasTitle`](/docs/extensions/html-attribute/reference/global/hastitle/index.md) |
| [`transform()`](#method-transform) | Sets the SVG `transform` attribute for the element. | `BaseSvg` |
| <span id="method-translate"></span>[`translate()`](/docs/extensions/html-attribute/reference/global/hastranslate/index.md#method-translate) | Sets the `translate` attribute. | [`UIAwesome\Html\Attribute\Global\HasTranslate`](/docs/extensions/html-attribute/reference/global/hastranslate/index.md) |
| [`viewBox()`](#method-viewBox) | Sets the SVG `viewBox` attribute for the element. | `BaseSvg` |
| [`width()`](#method-width) | Sets the `width` attribute. | `BaseSvg` |
| [`x()`](#method-x) | Sets the SVG `x` attribute for the element. | `BaseSvg` |
| [`xmlns()`](#method-xmlns) | Sets the `xmlns` attribute for the SVG element. | `BaseSvg` |
| [`y()`](#method-y) | Sets the SVG `y` attribute for the element. | `BaseSvg` |
| <span id="method-afterRun"></span>[`afterRun()`](/docs/extensions/html-core/reference/event/hasafterrun/index.md#method-afterRun) protected | Post-processes rendered output. | [`UIAwesome\Html\Core\Event\HasAfterRun`](/docs/extensions/html-core/reference/event/hasafterrun/index.md) |
| [`beforeRun()`](#method-beforeRun) protected | Pre-run validation for SVG rendering. | `BaseSvg` |
| <span id="method-getTag"></span>[`getTag()`](/docs/extensions/html-core/reference/element/baseblock/index.md#method-getTag) protected abstract | Returns the tag instance representing the block element. | [`UIAwesome\Html\Core\Element\BaseBlock`](/docs/extensions/html-core/reference/element/baseblock/index.md) |
| <span id="method-isBeginExecuted"></span>[`isBeginExecuted()`](/docs/extensions/html-core/reference/element/baseblock/index.md#method-isBeginExecuted) protected | Indicates whether this instance has an open or closing operation in the current context. | [`UIAwesome\Html\Core\Element\BaseBlock`](/docs/extensions/html-core/reference/element/baseblock/index.md) |
| <span id="method-loadDefault"></span>[`loadDefault()`](/docs/extensions/html-core/reference/base/basetag/index.md#method-loadDefault) protected | Returns class-level default definitions. | [`UIAwesome\Html\Core\Base\BaseTag`](/docs/extensions/html-core/reference/base/basetag/index.md) |
| [`run()`](#method-run) protected | Executes the rendering routine for the SVG element. | `BaseSvg` |
| <span id="method-runBegin"></span>[`runBegin()`](/docs/extensions/html-core/reference/element/baseblock/index.md#method-runBegin) protected | Returns the opening tag for begin/end rendering. | [`UIAwesome\Html\Core\Element\BaseBlock`](/docs/extensions/html-core/reference/element/baseblock/index.md) |

## Method details

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

```php
public function filePath(string $value): static
```

Sets the file path for the SVG file to be rendered.

Creates a new instance with the specified file path property value, supporting explicit assignment of SVG file
paths.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | Path to the SVG file. |

**Returns**

`static`: New instance with the updated `filePath` property. Usage example: $element->filePath('/path/to/icon.svg');

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

```php
public function fill(string|null $value): static
```

Sets the SVG `fill` attribute for the element.

Creates a new instance with the specified fill value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|null` | Fill value (for example, 'red', 'url(#gradient1)', or `null` to unset). |

**Returns**

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

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

```php
public function fillOpacity(float|int|string|null $value): static
```

Sets SVG `fill-opacity` attribute for the element.

Creates a new instance with the specified fill opacity value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `float\|int\|string\|null` | Fill opacity value (for example, '0.5', 0.5, or `null` to unset). |

**Returns**

`static`: New instance with the updated `fill-opacity` attribute.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): if the value is outside the allowed range ('0'-'1') and not `null`.

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

```php
public function fillRule(UIAwesome\Html\Svg\Values\FillRule|string|null $value): static
```

Sets SVG `fill-rule` attribute for the element.

Creates a new instance with the specified fill rule value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | [`UIAwesome\Html\Svg\Values\FillRule`](/docs/extensions/html-svg/reference/values/fillrule/index.md)`\|string\|null` | Fill rule value to set for the element. Accepts 'nonzero', 'evenodd', [`FillRule`](/docs/extensions/html-svg/reference/values/fillrule/index.md) enum, or `null` to unset. |

**Returns**

`static`: New instance with the updated `fill-rule` attribute.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): if the provided value is not a valid [`FillRule`](/docs/extensions/html-svg/reference/values/fillrule/index.md) enum or string.

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

```php
public function getAttributes(): mixed[]
```

Overrides the attribute retrieval to filter out the `title` attribute.

This ensures `title` attribute is never rendered as a standard SVG attribute, without modifying the internal
state of the object.

**Returns**

`mixed[]`: Filtered attributes array without `title` attribute. Usage example: $element->getAttributes();

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

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

Retrieves the content of the SVG element, injecting a `<title>` element when defined.

Overrides the base implementation to intercept the `title` attribute. If present, it creates a `<title>` element
and prepends it to the content before the remaining SVG content.

**Returns**

`string`: Combined content string with the `title` attribute injected. Usage example: $element->getContent();

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

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

Sets the `height` attribute.

Usage example:
```php
$element->height(200);
$element->height('50%');
$element->height('auto');
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `int\|string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php)`\|null` | Height value in pixels or CSS units, or `null` to remove the attribute. |

**Returns**

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

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

```php
public function opacity(float|int|string|null $value): static
```

Sets the SVG `opacity` attribute for the element.

Creates a new instance with the specified opacity value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `float\|int\|string\|null` | Opacity value (for example, '0.5', '0.75', or `null` to unset). |

**Returns**

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

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): if the value is outside the allowed range ('0'-'1') and not `null`.

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

```php
public function preserveAspectRatio(UIAwesome\Html\Svg\Values\PreserveAspectRatio|string|null $value): static
```

Sets the SVG `preserveAspectRatio` attribute for the element.

Creates a new instance with the specified preserve aspect ratio value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | [`UIAwesome\Html\Svg\Values\PreserveAspectRatio`](/docs/extensions/html-svg/reference/values/preserveaspectratio/index.md)`\|string\|null` | Preserve aspect ratio value (for example, 'xMidYMid meet', [`PreserveAspectRatio`](/docs/extensions/html-svg/reference/values/preserveaspectratio/index.md) enum, or `null` to unset). |

**Returns**

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

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): if the provided value is not a valid [`PreserveAspectRatio`](/docs/extensions/html-svg/reference/values/preserveaspectratio/index.md) enum or string.

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

```php
public function stroke(string|null $value): static
```

Sets the SVG `stroke` attribute for the element.

Creates a new instance with the specified stroke value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|null` | Stroke paint value (for example, 'black', 'url(#gradient1)', or `null` to unset). |

**Returns**

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

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

```php
public function strokeDashArray(float|int|string|null $value): static
```

Sets the SVG `stroke-dasharray` attribute for the element.

Creates a new instance with the specified dash array value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `float\|int\|string\|null` | Dash array value (for example, '5.3', '4', '5.3 2', or `null` to unset). |

**Returns**

`static`: New instance with the updated `stroke-dasharray` attribute.

**See also**

- <https://www.w3.org/TR/SVG2/painting.html#StrokeDashing> (Usage example: $element->strokeDashArray(5.3); $element->strokeDashArray(4); $element->strokeDashArray(null);)

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

```php
public function strokeLineCap(string|UIAwesome\Html\Svg\Values\StrokeLineCap|null $value): static
```

Sets the SVG `stroke-linecap` attribute for the element.

Creates a new instance with the specified stroke line cap value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|`[`UIAwesome\Html\Svg\Values\StrokeLineCap`](/docs/extensions/html-svg/reference/values/strokelinecap/index.md)`\|null` | Stroke line cap style (for example, 'round', [`StrokeLineCap`](/docs/extensions/html-svg/reference/values/strokelinecap/index.md) enum, or `null` to unset). |

**Returns**

`static`: New instance with the updated `stroke-linecap` attribute.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): if the provided value is not a valid [`StrokeLineCap`](/docs/extensions/html-svg/reference/values/strokelinecap/index.md) enum or string.

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

```php
public function strokeLineJoin(string|UIAwesome\Html\Svg\Values\StrokeLineJoin|null $value): static
```

Sets the SVG `stroke-linejoin` attribute for the element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|`[`UIAwesome\Html\Svg\Values\StrokeLineJoin`](/docs/extensions/html-svg/reference/values/strokelinejoin/index.md)`\|null` | Stroke line join style (for example, 'miter', [`StrokeLineJoin`](/docs/extensions/html-svg/reference/values/strokelinejoin/index.md) enum, or `null` to unset). |

**Returns**

`static`: New instance with the updated `stroke-linejoin` attribute.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): if the provided value is not a valid [`StrokeLineJoin`](/docs/extensions/html-svg/reference/values/strokelinejoin/index.md) enum or string.

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

```php
public function strokeMiterlimit(float|int|string|null $value): static
```

Sets SVG `stroke-miterlimit` attribute for the element.

Creates a new instance with the specified stroke miter limit value for the rendered element.

The `stroke-miterlimit` attribute controls the limit on the ratio of the miter length to the stroke width. When
the limit is exceeded, the join is converted from a miter to a bevel. The value must be a number '>= 1'.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `float\|int\|string\|null` | Stroke miter limit value (for example, '4', '10', or `null` to unset). |

**Returns**

`static`: New instance with the updated `stroke-miterlimit` attribute.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): if value is not a number '>= 1' or `null`.

**See also**

- <https://www.w3.org/TR/SVG2/painting.html#StrokeMiterlimitProperty> (Usage example: $element->strokeMiterlimit(4); $element->strokeMiterlimit(null);)

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

```php
public function strokeOpacity(float|int|string|null $value): static
```

Sets SVG `stroke-opacity` attribute for the element.

Creates a new instance with the specified stroke opacity value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `float\|int\|string\|null` | Stroke opacity value (for example, '0.8', '0.6', or `null` to unset). |

**Returns**

`static`: New instance with the updated `stroke-opacity` attribute.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): if the value is outside the allowed range ('0'-'1') and not `null`.

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

```php
public function strokeWidth(int|string|null $value): static
```

Sets the SVG `stroke-width` attribute for the element.

Creates a new instance with the specified stroke width value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `int\|string\|null` | Stroke width value (for example, '2', '1.5em', or `null` to unset). |

**Returns**

`static`: New instance with the updated `stroke-width` attribute.

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

```php
public function transform(string|null $value): static
```

Sets the SVG `transform` attribute for the element.

Creates a new instance with the specified transform value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|null` | Transform value (for example, 'rotate(45)', 'scale(2)', or `null` to unset). |

**Returns**

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

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

```php
public function viewBox(string|null $value): static
```

Sets the SVG `viewBox` attribute for the element.

Creates a new instance with the specified view box value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|null` | ViewBox value (for example, '0 0 100 100', or `null` to unset). |

**Returns**

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

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

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

Sets the `width` attribute.

Usage example:
```php
$element->width(400);
$element->width('50%');
$element->width('auto');
$element->width(null);
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `int\|string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php)`\|null` | Width value in pixels or CSS units, or `null` to remove the attribute. |

**Returns**

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

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

```php
public function x(float|int|string|null $value): static
```

Sets the SVG `x` attribute for the element.

Creates a new instance with the specified x-coordinate value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `float\|int\|string\|null` | X coordinate value (for example, '10', '10.3', '50%', or `null` to unset). |

**Returns**

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

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

```php
public function xmlns(string|null $value): static
```

Sets the `xmlns` attribute for the SVG element.

Creates a new instance with the specified XML namespace URI for the rendered `<svg>` element.

The `xmlns` attribute is typically used on the outermost `<svg>` element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|null` | XML namespace URI. |

**Returns**

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

**See also**

- <https://svgwg.org/svg2-draft/struct.html#Namespace> (Usage example: $element->xmlns('http://www.w3.org/2000/svg');)

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

```php
public function y(float|int|string|null $value): static
```

Sets the SVG `y` attribute for the element.

Creates a new instance with the specified y-coordinate value for the rendered element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `float\|int\|string\|null` | Y coordinate value (for example, '20', '10.3', '50%', or `null` to unset). |

**Returns**

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

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

```php
protected function beforeRun(): bool
```

Pre-run validation for SVG rendering.

Ensures at least one source of content is provided: either the `filePath` property or the internal `content`.

**Returns**

`bool`: `true` when preconditions are satisfied and the parent pre-run succeeds.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): if both `filePath` and `content` are empty.

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

```php
protected function run(): string
```

Executes the rendering routine for the SVG element.

If a `filePath` is configured the SVG content is loaded, sanitized, and injected into the current document. When
no `filePath` is provided the parent's run method is used.

**Returns**

`string`: Rendered SVG string or parent's result.