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

# filter

APISummary
## Introduction

The `filter` CSS property applies graphical effects like blur or color shift to an element.

:::info

Currently only the `blur`, `grayscale`, `brightness`, `contrast` and `saturate` functions are supported.

If you use `opacity`, you can directly set properties for the view, [link](/next/api/css/properties/opacity.md)

Views with the `grayscale` attribute added on Android will create off-screen buffer on the GPU. A large number of off-screen buffer will cause rendering performance to decrease. It is recommended to replace `filter: grayscale(0)` with `filter: none` to remove off-screen caching when grayscale is not needed.

:::

:::info Android blur (OS Version \< 12)

When using blur, you can add `blur-sampling` property (an int value) to the node to set the downsampling ratio to improve performance.

Setting the blur area may cause performance issues if content is updated all the time.

For higher blur efficiency, it is recommended that the actual size of the blur-radius should not exceed 25, that is, the maximum write 25ppx or 25/density px.

:::

## Examples

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

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

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

const Filter = () => {
  const blurStyle = {
    filter: "blur(10px)",
  };

  const grayscaleStyle = {
    filter: "grayscale(100%)",
  };

  const brightnessStyle = {
    filter: "brightness(0.3)",
  };

  const contrastStyle = {
    filter: "contrast(0.5)",
  };

  const saturateStyle = {
    filter: "saturate(0.7)",
  };

  const imageStyle = {
    width: "100px",
    height: "140px",
  };

  return (
    <scroll-view className="w-100 h-100" scroll-orientation="vertical">
      <view style={blurStyle}>
        <image style={imageStyle} src={lynxImage} />
      </view>
      <view style={grayscaleStyle}>
        <image style={imageStyle} src={lynxImage} />
      </view>
      <view style={brightnessStyle}>
        <image style={imageStyle} src={lynxImage} />
      </view>
      <view style={contrastStyle}>
        <image style={imageStyle} src={lynxImage} />
      </view>
      <view style={saturateStyle}>
        <image style={imageStyle} src={lynxImage} />
      </view>
    </scroll-view>
  );
};

root.render(<Filter />);

```

v0.11.0



## Syntax

```css
filter: grayscale(100%);
filter: blur(5px);
filter: brightness(0.6);
filter: contrast(0.7);
filter: saturate(0.8);
```

## Formal definition

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


## Formal Syntax

```
filter = <filter-function>

<filter-function> =
  <blur()>         |
  <grayscale()>    |

<blur()> =
  blur( <length>? )

<grayscale()> =
  grayscale( [ <percentage> ]? )

<brightness()> =
  brightness( [ <number> | <percentage> ]? )

<contrast()> =
  contrast( [ <number> | <percentage> ]? )

<saturate()> =
  saturate( [ <number> | <percentage> ]? )

```

## Differences from the Web

- Only one filter function is allowed per declaration
- Only supports `blur`, `grayscale`, `brightness`, `contrast` and `saturate` functions

## Compatibility

**Compatibility Table**

**Query:** `css.properties.filter`

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| filter | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| blur | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| grayscale | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| brightness | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes |
| contrast | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes |
| saturate | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes |

**`filter`**

**Specifications:**

**`blur`**

**Specifications:**

**`grayscale`**

**Specifications:**

**`brightness`**

**Specifications:**

**`contrast`**

**Specifications:**

**`saturate`**

**Specifications:**

