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

# opacity

APISummary
## Introduction

The opacity CSS property sets the opacity of an element. Opacity is the degree to which content behind an element is hidden, and is the opposite of transparency.

Opacity applies to the element as a whole, including its contents, even though the value is not inherited by child elements.
Thus, the element and its children all have the same opacity relative to the element's background, even if they have different opacities relative to one another.

:::caution
The group opacity on Android is true by default, while on iOS is false. Use `overlap` and `overlap-ios` to define how opacity affects the background and contents of the view.

Group opacity will force the system to use off-screen rendering to render the view, which has performance issues on both Android and iOS.
And, on Android, the `overflow: visible` will lose effect.
:::

## Examples

**This is an example below: css-api**

**Entry:** `src/opacity`
**Bundle:** `dist/opacity.lynx.bundle`

```tsx
import { root } from "@lynx-js/react";
import "./index.scss";

import image from "../../resource/lynx.png";

const Opacity = () => {
  const heightStyle = {
    height: "10px",
  };

  const opacity1Style = {
    opacity: 1,
  };

  const opacity05Style = {
    opacity: 0.5,
  };

  const opacity0Style = {
    opacity: 0,
  };

  return (
    <scroll-view className="root" scroll-orientation="vertical">
      <view className="fixed_area">
        <image className="relative_image" src={image}></image>
        <view style={heightStyle}></view>
        <image className="relative_image" style={opacity1Style} src={image}></image>
        <view style={heightStyle}></view>
        <image className="relative_image" style={opacity05Style} src={image}></image>
        <view style={heightStyle}></view>
        <image className="relative_image" style={opacity0Style} src={image}></image>
      </view>
    </scroll-view>
  );
};

root.render(<Opacity />);

```

v0.11.0



## Syntax

```css
opacity: 1;
opacity: 0.5;
opacity: 0;
```

### Values

A \<number> in the range `0.0` to `1.0`, inclusive, or a \<percentage> in the range `0%` to `100%`, inclusive, representing the opacity of the channel
(that is, the value of its alpha channel). Any value outside the interval, though valid, is clamped to the nearest limit in the range.

|                  Value                 |                                    Meaning                                    |
| :------------------------------------: | :---------------------------------------------------------------------------: |
|                    0                   |             The element is fully transparent (that is, invisible).            |
| Any \<number> strictly between 0 and 1 | The element is translucent (that is, content behind the element can be seen). |
|                    1                   |                 The element is fully opaque (visually solid).                 |

## Formal definition

| Initial value | 1 |
| Applies to | all elements |
| Inherited | no |
| Animatable | yes |


## Formal syntax

opacity: `<number>`;

## Differences from the Web

Opacity will affect the background and contents as a whole. For Lynx iOS should set `overlap-ios={true}`.

## Compatibility

**Compatibility Table**

**Query:** `css.properties.opacity`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/23-opacity.json) · [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/opacity)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| opacity | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |

**`opacity`**

**Specifications:**

