Svg
API reference › HTML SVG › Svg
Represents the SVG <svg> (svg) element for scalable vector graphics containers.
Provides a concrete implementation of the SVG <svg> container element that returns SvgBlock::SVG and
inherits attribute methods from BaseSvg for viewport, paint, and transform attributes.
The <svg> element defines a new coordinate system and viewport for SVG graphics. It is used as the outermost
element of SVG documents, or to embed SVG fragments within HTML or SVG documents.
Usage example:
use UIAwesome\Html\Svg\{Circle, Svg};
echo Svg::tag() ->xmlns('http://www.w3.org/2000/svg') ->viewBox('0 0 100 100') ->title('Circle example') ->content(Circle::tag()->cx(50)->cy(50)->r(40)->fill('currentColor')) ->render();See also: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg (BaseSvg for the base implementation.).
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$attributes protected | mixed[] | HTML attributes array used by the implementing class. Default: []. | UIAwesome\ |
$content protected | string | Content string assigned to the element. Default: ''. | UIAwesome\ |
Methods
Section titled “Methods”Method details
Section titled “Method details”icon()
Section titled “icon() ”public static function icon(string $reference): selfReturns a new Svg instance configured to render an icon bundled with the package.
Accepts a reference of the form Collection:name (for example, Bootstrap5:globe). Icons resolve against the
path assets/icons/{Collection}/{name}.svg shipped with this package. Chain additional fluent methods (width,
height, fill, …) before rendering.
Usage example:
echo \UIAwesome\Html\Svg\Svg::icon('Bootstrap5:globe') ->width(32) ->height(32) ->fill('currentColor') ->render();Parameters
| Parameter | Type | Description |
|---|---|---|
$reference | string | Icon reference in the form Collection:name. Each segment must match [A-Za-z0-9_-]+. |
Returns
self: New instance with the resolved SVG file path configured.
Throws
InvalidArgumentException: if$referencedoes not match theCollection:nameformat, or if the resolved path is not a bundled SVG file.
iconPath()
Section titled “iconPath() ”public static function iconPath(string $reference): stringResolves an icon reference to the absolute file path of the SVG asset shipped with this package.
Accepts a reference of the form Collection:name (for example, Bootstrap5:globe). Useful when the file path is
needed without instantiating a Svg (for example, when configuring iconFilePath() on another
component).
Usage example:
$component->iconFilePath(\UIAwesome\Html\Svg\Svg::iconPath('Bootstrap5:globe'));Parameters
| Parameter | Type | Description |
|---|---|---|
$reference | string | Icon reference in the form Collection:name. Each segment must match [A-Za-z0-9_-]+; references containing path separators, .., or empty segments are rejected to keep the resolved path inside the bundled assets/icons directory. |
Returns
string: Absolute path to the resolved SVG file.
Throws
InvalidArgumentException: if$referencedoes not match theCollection:nameformat, or if the resolved path is not a bundled SVG file.
getTag()
Section titled “getTag() ”protected function getTag(): BackedEnumReturns the tag enumeration for the <svg> element.
Returns
BackedEnum: Tag enumeration instance for <svg>. SvgBlock for valid SVG block-level tags.