G
API reference › HTML SVG › G
Represents the SVG <g> (group) element for grouping and transforming SVG content.
Provides a concrete <g> element implementation that returns SvgBlock::G and provides paint and transform
attribute methods.
The <g> element groups SVG shapes and other elements, allowing shared attributes and transforms.
Usage example:
use UIAwesome\Html\Svg\{Circle, G};
echo G::tag() ->transform('translate(20 20)') ->opacity(0.8) ->content(Circle::tag()->cx(10)->cy(10)->r(4)->fill('currentColor')) ->render();See also: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/g (BaseBlock for the base block-level 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”fill()
Section titled “fill() ”public function fill(string|null $value): staticSets 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| | Fill value (for example, ‘red’, ‘url(#gradient1)’, or null to unset). |
Returns
static: New instance with the updated fill attribute.
fillOpacity()
Section titled “fillOpacity() ”public function fillOpacity(float|int|string|null $value): staticSets 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| | Fill opacity value (for example, ‘0.5’ or null to unset). |
Returns
static: New instance with the updated fill-opacity attribute.
Throws
InvalidArgumentException: If the value is outside the allowed range (‘0’-‘1’) and notnull.
fillRule()
Section titled “fillRule() ”public function fillRule(UIAwesome\Html\Svg\Values\FillRule|string|null $value): staticSets 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\| | Fill rule value to set for the element. Accepts ‘nonzero’, ‘evenodd’, FillRule enum, or null to unset. |
Returns
static: New instance with the updated fill-rule attribute.
Throws
InvalidArgumentException: If the provided value is not a validFillRuleenum or string.
opacity()
Section titled “opacity() ”public function opacity(float|int|string|null $value): staticSets 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| | Opacity value (for example, ‘0.5’ or null to unset). |
Returns
static: New instance with the updated opacity attribute.
Throws
InvalidArgumentException: If the value is outside the allowed range (‘0’-‘1’) and notnull.
stroke()
Section titled “stroke() ”public function stroke(string|null $value): staticSets 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| | Stroke paint value (for example, ‘black’, ‘url(#gradient1)’, or null to unset). |
Returns
static: New instance with the updated stroke attribute.
strokeDashArray()
Section titled “strokeDashArray() ”public function strokeDashArray(float|int|string|null $value): staticSets 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| | Dash array value (for example, ‘5.3’ 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()
Section titled “strokeLineCap() ”public function strokeLineCap(string|UIAwesome\Html\Svg\Values\StrokeLineCap|null $value): staticSets 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\| | Stroke line cap style (for example, ‘round’, StrokeLineCap enum, or null to unset). |
Returns
static: New instance with the updated stroke-linecap attribute.
Throws
InvalidArgumentException: If the provided value is not a validStrokeLineCapenum or string.
strokeLineJoin()
Section titled “strokeLineJoin() ”public function strokeLineJoin(string|UIAwesome\Html\Svg\Values\StrokeLineJoin|null $value): staticSets the SVG stroke-linejoin attribute for the element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string|UIAwesome\| | Stroke line join style (for example, ‘miter’, StrokeLineJoin enum, or null to unset). |
Returns
static: New instance with the updated stroke-linejoin attribute.
Throws
InvalidArgumentException: If the provided value is not a validStrokeLineJoinenum or string.
strokeMiterlimit()
Section titled “strokeMiterlimit() ”public function strokeMiterlimit(float|int|string|null $value): staticSets 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| | Stroke miter limit value (for example, ‘4’ or null to unset). |
Returns
static: New instance with the updated stroke-miterlimit attribute.
Throws
InvalidArgumentException: If value is not a number ’>= 1’ ornull.
See also
- https://www.w3.org/TR/SVG2/painting.html#StrokeMiterlimitProperty (Usage example: $element->strokeMiterlimit(4); $element->strokeMiterlimit(null);)
strokeOpacity()
Section titled “strokeOpacity() ”public function strokeOpacity(float|int|string|null $value): staticSets 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| | Stroke opacity value (for example, ‘0.8’ or null to unset). |
Returns
static: New instance with the updated stroke-opacity attribute.
Throws
InvalidArgumentException: If the value is outside the allowed range (‘0’-‘1’) and notnull.
strokeWidth()
Section titled “strokeWidth() ”public function strokeWidth(int|string|null $value): staticSets 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| | Stroke width value (for example, ‘2’, ‘1.5em’, or null to unset). |
Returns
static: New instance with the updated stroke-width attribute.
transform()
Section titled “transform() ”public function transform(string|null $value): staticSets 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| | Transform value (for example, ‘rotate(45)’, ‘scale(2)’, or null to unset). |
Returns
static: New instance with the updated transform attribute.
getTag()
Section titled “getTag() ”protected function getTag(): BackedEnumReturns the tag enumeration for the <g> element.
Returns
BackedEnum: Tag enumeration instance for <g>. SvgBlock for valid SVG block-level tags.