Skip to content
PHP Ecosystem
Explore

Rect

API reference › HTML SVG › Rect

Represents the SVG <rect> (rectangle) element for rendering rectangles.

Provides a concrete <rect> element implementation that returns SvgVoid::RECT and provides geometry, paint, and transform attribute methods.

The <rect> element is an SVG basic shape used to create rectangles based on position and size attributes.

See also: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/rect (BaseVoid for the base implementation.).

PropertyTypeDescriptionDefined by
$attributes protectedmixed[]HTML attributes array used by the implementing class. Default: [].UIAwesome\Html\Mixin\HasAttributes
MethodDescriptionDefined by
__construct() finalInitializes a new tag instance.UIAwesome\Html\Core\Base\BaseTag
__toString()Returns the rendered tag string.UIAwesome\Html\Core\Base\BaseTag
accesskey()Sets the accesskey attribute.UIAwesome\Html\Attribute\Global\HasAccesskey
addAriaAttribute()Sets an aria-* attribute.UIAwesome\Html\Attribute\Global\HasAria
addAttribute()Adds or updates a single HTML attribute for the element.UIAwesome\Html\Mixin\HasAttributes
addDataAttribute()Sets a data-* attribute.UIAwesome\Html\Attribute\Global\HasData
addEvent()Sets an on* event attribute.UIAwesome\Html\Attribute\Global\HasEvents
ariaAttributes()Sets multiple aria-* attributes.UIAwesome\Html\Attribute\Global\HasAria
attributes()Adds or updates multiple HTML attributes for the element.UIAwesome\Html\Mixin\HasAttributes
class()Sets the class attribute.UIAwesome\Html\Attribute\Global\HasClass
config()Applies application-scoped config recipes to this tag.UIAwesome\Html\Core\Base\BaseTag
dataAttributes()Sets multiple data-* attributes.UIAwesome\Html\Attribute\Global\HasData
dir()Sets the dir attribute.UIAwesome\Html\Attribute\Global\HasDir
events()Sets multiple on* event attributes.UIAwesome\Html\Attribute\Global\HasEvents
fill()Sets the SVG fill attribute for the element.Rect
fillOpacity()Sets SVG fill-opacity attribute for the element.Rect
fillRule()Sets SVG fill-rule attribute for the element.Rect
getAttribute()Returns the value of a single HTML attribute.UIAwesome\Html\Mixin\HasAttributes
getAttributes()Returns the array of HTML attributes for the element.UIAwesome\Html\Mixin\HasAttributes
height()Sets the height attribute.Rect
hidden()Sets the hidden attribute.UIAwesome\Html\Attribute\Global\CanBeHidden
id()Sets the id attribute.UIAwesome\Html\Attribute\Global\HasId
lang()Sets the lang attribute.UIAwesome\Html\Attribute\Global\HasLang
opacity()Sets the SVG opacity attribute for the element.Rect
pathLength()Sets the SVG pathLength attribute for the element.Rect
removeAriaAttribute()Removes an aria-* attribute.UIAwesome\Html\Attribute\Global\HasAria
removeAttribute()Removes a specific HTML attribute from the element.UIAwesome\Html\Mixin\HasAttributes
removeDataAttribute()Removes a data-* attribute.UIAwesome\Html\Attribute\Global\HasData
removeEvent()Removes an on* event attribute.UIAwesome\Html\Attribute\Global\HasEvents
render() finalRenders the tag with lifecycle hooks.UIAwesome\Html\Core\Base\BaseTag
replaceAttributes()Replaces all HTML attributes for the element.UIAwesome\Html\Mixin\HasAttributes
role()Sets the role attribute.UIAwesome\Html\Attribute\Global\HasRole
rx()Sets the SVG rx attribute for the element.Rect
ry()Sets the SVG ry attribute for the element.Rect
stroke()Sets the SVG stroke attribute for the element.Rect
strokeDashArray()Sets the SVG stroke-dasharray attribute for the element.Rect
strokeLineCap()Sets the SVG stroke-linecap attribute for the element.Rect
strokeLineJoin()Sets the SVG stroke-linejoin attribute for the element.Rect
strokeMiterlimit()Sets SVG stroke-miterlimit attribute for the element.Rect
strokeOpacity()Sets SVG stroke-opacity attribute for the element.Rect
strokeWidth()Sets the SVG stroke-width attribute for the element.Rect
style()Sets the style attribute.UIAwesome\Html\Attribute\Global\HasStyle
tag() staticCreates and configures a new tag instance.UIAwesome\Html\Core\Base\BaseTag
title()Sets the title attribute.UIAwesome\Html\Attribute\Global\HasTitle
transform()Sets the SVG transform attribute for the element.Rect
translate()Sets the translate attribute.UIAwesome\Html\Attribute\Global\HasTranslate
width()Sets the width attribute.Rect
x()Sets the SVG x attribute for the element.Rect
y()Sets the SVG y attribute for the element.Rect
afterRun() protectedPost-processes rendered output.UIAwesome\Html\Core\Event\HasAfterRun
beforeRun() protectedValidates state before rendering.UIAwesome\Html\Core\Event\HasBeforeRun
getTag() protectedReturns the tag enumeration for the <rect> element.Rect
loadDefault() protectedReturns class-level default definitions.UIAwesome\Html\Core\Base\BaseTag
run() protectedRenders the void element.UIAwesome\Html\Core\Element\BaseVoid
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

ParameterTypeDescription
$valuestring|nullFill value (for example, ‘red’, ‘url(#gradient1)’, or null to unset).

Returns

static: New instance with the updated fill attribute.

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

ParameterTypeDescription
$valuefloat|int|string|nullFill opacity value (for example, ‘0.5’ or null to unset).

Returns

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

Throws

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

ParameterTypeDescription
$valueUIAwesome\Html\Svg\Values\FillRule|string|nullFill 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

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

Sets the height attribute.

Usage example:

$element->height(200);
$element->height('50%');
$element->height('auto');

Parameters

ParameterTypeDescription
$valueint|string|Stringable|UnitEnum|nullHeight value in pixels or CSS units, or null to remove the attribute.

Returns

static: New instance with the updated height attribute.

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

ParameterTypeDescription
$valuefloat|int|string|nullOpacity value (for example, ‘0.5’ or null to unset).

Returns

static: New instance with the updated opacity attribute.

Throws

public function pathLength(float|int|string|null $value): static

Sets the SVG pathLength attribute for the element.

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

Parameters

ParameterTypeDescription
$valuefloat|int|string|nullPath length value (for example, ‘100’, ‘50.5’, or null to unset).

Returns

static: New instance with the updated pathLength attribute.

Throws

See also

public function rx(float|int|string|null $value): static

Sets the SVG rx attribute for the element.

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

Parameters

ParameterTypeDescription
$valuefloat|int|string|nullX-axis radius value (for example, ‘50’, ‘10px’, ‘50%’, or null to unset).

Returns

static: New instance with the updated rx attribute.

public function ry(float|int|string|null $value): static

Sets the SVG ry attribute for the element.

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

Parameters

ParameterTypeDescription
$valuefloat|int|string|nullY-axis radius value (for example, ‘50’, ‘10px’, ‘50%’, or null to unset).

Returns

static: New instance with the updated ry attribute.

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

ParameterTypeDescription
$valuestring|nullStroke paint value (for example, ‘black’, ‘url(#gradient1)’, or null to unset).

Returns

static: New instance with the updated stroke attribute.

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

ParameterTypeDescription
$valuefloat|int|string|nullDash array value (for example, ‘5.3’ or null to unset).

Returns

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

See also

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

ParameterTypeDescription
$valuestring|UIAwesome\Html\Svg\Values\StrokeLineCap|nullStroke line cap style (for example, 'round', StrokeLineCap enum, or null to unset).

Returns

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

Throws

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

Sets the SVG stroke-linejoin attribute for the element.

Parameters

ParameterTypeDescription
$valuestring|UIAwesome\Html\Svg\Values\StrokeLineJoin|nullStroke line join style (for example, ‘miter’, StrokeLineJoin enum, or null to unset).

Returns

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

Throws

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

ParameterTypeDescription
$valuefloat|int|string|nullStroke miter limit value (for example, ‘4’ or null to unset).

Returns

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

Throws

See also

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

ParameterTypeDescription
$valuefloat|int|string|nullStroke opacity value (for example, ‘0.8’ or null to unset).

Returns

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

Throws

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

ParameterTypeDescription
$valueint|string|nullStroke width value (for example, ‘2’, ‘1.5em’, or null to unset).

Returns

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

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

ParameterTypeDescription
$valuestring|nullTransform value (for example, ‘rotate(45)’, ‘scale(2)’, or null to unset).

Returns

static: New instance with the updated transform attribute.

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

Sets the width attribute.

Usage example:

$element->width(400);
$element->width('50%');
$element->width('auto');
$element->width(null);

Parameters

ParameterTypeDescription
$valueint|string|Stringable|UnitEnum|nullWidth value in pixels or CSS units, or null to remove the attribute.

Returns

static: New instance with the updated width attribute.

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

ParameterTypeDescription
$valuefloat|int|string|nullX coordinate value (for example, ‘10’, ‘10.3’, ‘50%’, or null to unset).

Returns

static: New instance with the updated x attribute.

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

ParameterTypeDescription
$valuefloat|int|string|nullY coordinate value (for example, ‘20’, ‘10.3’, ‘50%’, or null to unset).

Returns

static: New instance with the updated y attribute.

protected function getTag(): BackedEnum

Returns the tag enumeration for the <rect> element.

Returns

BackedEnum: Tag enumeration instance for <rect>. SvgVoid for valid SVG void-level tags.