Skip to content

getStyle

getStyle(element, property): string

Defined in: core/dom/styles.ts:52

Returns the computed value of a CSS property, e.g. '10px'. It is '' if the property does not exist.

Pass an array of properties to read several at once. The result then maps each property to its value.

Properties are CSS names, with hyphens: 'margin-right', not 'marginRight'. Note that setStyles takes camelCase names instead.

Element

Element to read from.

string

CSS property name.

string

getStyle(box, 'margin-right'); // '10px'
getStyle(box, ['margin-right', 'margin-left']); // { 'margin-right': '10px', 'margin-left': '10px' }

getStyle(element, properties): Record<string, string>

Defined in: core/dom/styles.ts:57

Element

Element to read from.

string[]

CSS property names.

Record<string, string>