LinearGradient
API reference › HTML SVG › LinearGradient
Represents the SVG <linearGradient> (linearGradient) element for defining linear gradients.
Provides a concrete <linearGradient> element implementation that returns SvgBlock::LINEAR_GRADIENT and
provides gradient and coordinate attribute methods.
The <linearGradient> element defines a linear gradient with coordinates and gradient attributes.
Usage example:
use UIAwesome\Html\Svg\{LinearGradient, Stop};
echo LinearGradient::tag() ->id('accent') ->x1('0%') ->y1('0%') ->x2('100%') ->y2('0%') ->content( Stop::tag()->offset('0%')->stopColor('#0ea5e9')->stopOpacity(1), Stop::tag()->offset('100%')->stopColor('#1d4ed8')->stopOpacity(1), ) ->render();See also: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient (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”gradientTransform()
Section titled “gradientTransform() ”public function gradientTransform(string|null $value): staticSets the SVG gradientTransform attribute for the gradient element.
Creates a new instance with the specified gradient 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 gradientTransform attribute.
gradientUnits()
Section titled “gradientUnits() ”public function gradientUnits(UIAwesome\Html\Svg\Values\CoordinateUnits|string|null $value): staticSets the SVG gradientUnits attribute for the gradient element.
Creates a new instance with the specified gradient units value for the rendered element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | UIAwesome\| | Gradient units value (for example, ‘userSpaceOnUse’, CoordinateUnits enum, or null to unset). |
Returns
static: New instance with the updated gradientUnits attribute.
Throws
InvalidArgumentException: If the provided value is not a validCoordinateUnitsenum or string.
spreadMethod()
Section titled “spreadMethod() ”public function spreadMethod(UIAwesome\Html\Svg\Values\SpreadMethod|string|null $value): staticSets the SVG spreadMethod attribute for the gradient element.
Creates a new instance with the specified spread method value for the rendered element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | UIAwesome\| | Spread method value (for example, ‘pad’, SpreadMethod enum, or null to unset). |
Returns
static: New instance with the updated spreadMethod attribute.
Throws
InvalidArgumentException: If the provided value is not a validSpreadMethodenum or string.
public function x1(float|int|string|null $value): staticSets the SVG x1 attribute for the element.
Creates a new instance with the specified first x-coordinate value for the rendered element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | float| | First x coordinate value (for example, ‘10’, ‘50%’, or null to unset). |
Returns
static: New instance with the updated x1 attribute.
public function x2(float|int|string|null $value): staticSets the SVG x2 attribute for the element.
Creates a new instance with the specified second x-coordinate value for the rendered element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | float| | Second x coordinate value (for example, ‘10’, ‘50%’, or null to unset). |
Returns
static: New instance with the updated x2 attribute.
public function y1(float|int|string|null $value): staticSets the SVG y1 attribute for the element.
Creates a new instance with the specified first y-coordinate value for the rendered element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | float| | First y coordinate value (for example, ‘10’, ‘50%’, or null to unset). |
Returns
static: New instance with the updated y1 attribute.
public function y2(float|int|string|null $value): staticSets the SVG y2 attribute for the element.
Creates a new instance with the specified second y-coordinate value for the rendered element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | float| | Second y coordinate value (for example, ‘10’, ‘50%’, or null to unset). |
Returns
static: New instance with the updated y2 attribute.
getTag()
Section titled “getTag() ”protected function getTag(): BackedEnumReturns the tag enumeration for the <linearGradient> element.
Returns
BackedEnum: Tag enumeration instance for <linearGradient>. SvgBlock for valid SVG block-level tags.