> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# `__GetComputedStyleByKey`

APISummary
## Introduction

Returns the resolved style value for a CSS property of an element

## Syntax

```jsx
__GetComputedStyleByKey(element: Element, key: string) : string;
```

### Parameters

|   Key   | Description                                                                                                                                                                              |
| :-----: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| element | Any Element object.                                                                                                                                                                      |
|   key   | A string indicating the CSS property key to be retrieved. Keep in mind that not every CSS property is supported. Refer to the Compatibility table to see which properties are supported. |

### Return Value

Resolved style value for a CSS property of specified element.

:::caution
Unlike browser, this PAPI won't trigger document reflow.
:::

## Example

The frontend framework can retrieve resolved style value of an Element as follows.

```jsx
// main-thread.js
let page = __CreateElement('page', 0, {});

let element = __CreateElement('view', 0, {});
__SetInlineStyles(element, {
  top: '10px',
  left: '10px',
  right: '10px',
  bottom: '10px',
});

__AppendElement(page, element);
__FlushElementTree(page, {});

let width = __GetComputedStyleByKey(element, 'width');
```

## Compatability

**Compatibility Table**

**Query:** `elements.get-computed-style-supported-properties`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/elements/get-computed-style-supported-properties.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| get-computed-style-supported-properties | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes |
| top | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes |
| left | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes |
| width | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes |
| height | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes |
| right | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes |
| bottom | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes |
| transform | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes |
| transform-origin | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes |
| opacity | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes |
| color | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes |
| background-color | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes |
| direction | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes |
| z-index | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes |
| background-position | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes |
| filter | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes |
| margin &#38; margin-left &#38; margin-right &#38; margin-top &#38; margin-bottom | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes |
| padding &#38; padding-left &#38; padding-right &#38; padding-top &#38; padding-bottom | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes |
| border-width &#38; border-top-width &#38; border-bottom-width &#38; border-left-width &#38; border-right-width | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes |
| border-radius &#38; border-top-left-radius &#38; border-top-right-radius &#38; border-bottom-right-radius &#38; border-bottom-left-radius | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes |
| border-color &#38; border-top-color &#38; border-right-color &#38; border-bottom-color &#38; border-left-color | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes |
| Other CSS Properties | No | No | No | Unknown | Unknown | Yes |

**`get-computed-style-supported-properties`**

__GetComputedStyleByKey

**Status:** Experimental

**`top`**

top

**Status:** Experimental

**`left`**

left

**Status:** Experimental

**`width`**

width

**Status:** Experimental

**`height`**

height

**Status:** Experimental

**`right`**

right

**Status:** Experimental

**`bottom`**

bottom

**Status:** Experimental

**`transform`**

transform

**Status:** Experimental

**`transform-origin`**

transform-origin

**Status:** Experimental

**`opacity`**

opacity

**Status:** Experimental

**`color`**

color

**Status:** Experimental

**`background-color`**

background-color

**Status:** Experimental

**`direction`**

direction

**Status:** Experimental

**`z-index`**

z-index

**Status:** Experimental

**`background-position`**

background-position

**Status:** Experimental

**`filter`**

filter

**Status:** Experimental

**`margin & margin-left & margin-right & margin-top & margin-bottom`**

margin & margin-left & margin-right & margin-top & margin-bottom

**Status:** Experimental

**`padding & padding-left & padding-right & padding-top & padding-bottom`**

padding & padding-left & padding-right & padding-top & padding-bottom

**Status:** Experimental

**`border-width & border-top-width & border-bottom-width & border-left-width & border-right-width`**

border-width & border-top-width & border-bottom-width & border-left-width & border-right-width

**Status:** Experimental

**`border-radius & border-top-left-radius & border-top-right-radius & border-bottom-right-radius & border-bottom-left-radius`**

border-radius & border-top-left-radius & border-top-right-radius & border-bottom-right-radius & border-bottom-left-radius

**Status:** Experimental

**`border-color & border-top-color & border-right-color & border-bottom-color & border-left-color`**

border-color & border-top-color & border-right-color & border-bottom-color & border-left-color

**Status:** Experimental

**`Other CSS Properties`**

Other CSS Properties

