Mask
API reference › HTML SVG › Mask
Represents the SVG <mask> element for defining masking regions.
Provides a concrete <mask> element implementation that returns SvgBlock::MASK and provides mask and geometry
attribute methods.
The <mask> element defines a mask that can be applied to other elements.
Usage example:
use UIAwesome\Html\Svg\{Mask, Rect};use UIAwesome\Html\Svg\Values\MaskType;
echo Mask::tag() ->id('fade') ->maskType(MaskType::LUMINANCE) ->content(Rect::tag()->x(0)->y(0)->width(100)->height(100)->fill('currentColor')) ->render();See also: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/mask (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”height()
Section titled “height() ”public function height(int|string|Stringable|UnitEnum|null $value): staticSets the height attribute.
Usage example:
$element->height(200);$element->height('50%');$element->height('auto');Parameters
| Parameter | Type | Description |
|---|---|---|
$value | int|Stringable|UnitEnum| | Height value in pixels or CSS units, or null to remove the attribute. |
Returns
static: New instance with the updated height attribute.
maskContentUnits()
Section titled “maskContentUnits() ”public function maskContentUnits(UIAwesome\Html\Svg\Values\CoordinateUnits|string|null $value): staticSets the SVG maskContentUnits attribute for the <mask> element.
Creates a new instance with the specified mask content units value for the rendered element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | UIAwesome\| | Mask content units value (for example, ‘userSpaceOnUse’, CoordinateUnits enum, or null to unset). |
Returns
static: New instance with the updated maskContentUnits attribute.
Throws
InvalidArgumentException: If the provided value is not a validCoordinateUnitsenum or string.
maskType()
Section titled “maskType() ”public function maskType(UIAwesome\Html\Svg\Values\MaskType|string|null $value): staticSets the SVG mask-type attribute for the <mask> element.
Creates a new instance with the specified mask type value for the rendered element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | UIAwesome\| | Mask type value to set for the element. Accepts ‘alpha’, ‘luminance’, MaskType enum, or null to unset. |
Returns
static: New instance with the updated mask-type attribute.
Throws
InvalidArgumentException: If the provided value is not a validMaskTypeenum or string.
maskUnits()
Section titled “maskUnits() ”public function maskUnits(UIAwesome\Html\Svg\Values\CoordinateUnits|string|null $value): staticSets the SVG maskUnits attribute for the <mask> element.
Creates a new instance with the specified mask units value for the rendered element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | UIAwesome\| | Mask units value (for example, ‘objectBoundingBox’, CoordinateUnits enum, or null to unset). |
Returns
static: New instance with the updated maskUnits attribute.
Throws
InvalidArgumentException: If the provided value is not a validCoordinateUnitsenum or string.
width()
Section titled “width() ”public function width(int|string|Stringable|UnitEnum|null $value): staticSets the width attribute.
Usage example:
$element->width(400);$element->width('50%');$element->width('auto');$element->width(null);Parameters
| Parameter | Type | Description |
|---|---|---|
$value | int|Stringable|UnitEnum| | Width 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): staticSets 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| | X 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): staticSets 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| | Y coordinate value (for example, ‘20’, ‘10.3’, ‘50%’, or null to unset). |
Returns
static: New instance with the updated y attribute.
getTag()
Section titled “getTag() ”protected function getTag(): BackedEnumReturns the tag enumeration for the <mask> element.
Returns
BackedEnum: Tag enumeration instance for <mask>. SvgBlock for valid SVG block-level tags.