CodeAPI

Style

An object representing an element's styles.

Table of Contents

PROPERTIES

?
Store values associated with an object.
backgroundColorSets or gets the background color of an element.
borderColorSets or gets the border color of an element.
borderRadiusSets or gets the border radius of an element.
borderWidthSets or gets the border width of an element.
colorSets or gets the text color of an element.

backgroundColor

Sets or gets the background color of an element.

Description

The background color value is a string representing an rgbaColor in one of the following formats:

  • "red": One of 140 predefined color names.
  • "#FF0000": A hexidecimal rgb color value.
  • "rgb(255,0,0)": An rgb() function color value.
  • "#FF000000": A hexidecimal rgba color value.
  • "rgba(255,0,0,1.0)": An rgba() function color value.

Syntax

get backgroundColor(): string
set backgroundColor(value: string): void
TYPE
?
The kind of data the property stores.
string

Examples

Set the background color

$w("#myElement").style.backgroundColor = "rgba(255,0,0,0.5)";

Get the background color

let bgColor = $w("#myElement").style.backgroundColor;

borderColor

Sets or gets the border color of an element.

Description

The border color value is a string representing an rgbaColor in one of the following formats:

  • "red": One of 140 predefined color names.
  • "#FF0000": A hexidecimal rgb color value.
  • "rgb(255,0,0)": An rgb() function color value.
  • "#FF000000": A hexidecimal rgba color value.
  • "rgba(255,0,0,1.0)": An rgba() function color value.

Syntax

get borderColor(): string
set borderColor(value: string): void
TYPE
?
The kind of data the property stores.
string

Examples

Set the border color

$w("#myElement").style.borderColor = "rgba(255,0,0,0.5)";

Get the border color

let borderColor = $w("#myElement").style.borderColor;

borderRadius

Sets or gets the border radius of an element.

Description

The border radius value is a string representing the element's border radius in pixels. For example, "1px".

Syntax

get borderRadius(): string
set borderRadius(value: string): void
TYPE
?
The kind of data the property stores.
string

Examples

Set the border radius

$w("#myElement").style.borderRadius = "1px";

Get the border radius

let borderRadius = $w("#myElement").style.borderRadius; // "1px"

borderWidth

Sets or gets the border width of an element.

Description

The border width value is a string representing the element's border width in pixels. For example, "1px".

Syntax

get borderWidth(): string
set borderWidth(value: string): void
TYPE
?
The kind of data the property stores.
string

Examples

Set the border width

$w("#myElement").style.borderWidth = "1px";

Get the border width

let borderWidth = $w("#myElement").style.borderWidth; // "1px"

color

Sets or gets the text color of an element.

Description

The text color value is a string representing an rgbColor in one of the following formats:

Syntax

get color(): string
set color(value: string): void
TYPE
?
The kind of data the property stores.
string

Examples

Set the text color

$w("#myElement").style.color = "rgb(255,0,0)";

Get the text color

let color = $w("#myElement").style.color;