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

# clip-path

APISummary

## Introduction

The `clip-path` CSS property creates a clipping region that sets what part of an element should be shown. Parts that are inside the region are shown, while those outside are hidden.

:::warning

- `clip-path` takes effect only on `<view>` elements.

- android If this property is
  not work on Android，try to add a transparent background `background-color:
  transparent` to avoid the clipping process from being skipped by system.

:::

## Examples

### **inset**

 

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

**Entry:** `src/clip_path/inset`
**Bundle:** `dist/clip_path_inset.lynx.bundle`

```tsx {10}
import { root } from "@lynx-js/react";

import "../common.css";

function App() {
  return (
    <view
      className="container"
      style={{
        clipPath: "inset(30px super-ellipse 3 3 50px/50px)",
      }}
    >
    </view>
  );
}

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.11.0



### **circle**

 

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

**Entry:** `src/clip_path/circle`
**Bundle:** `dist/clip_path_circle.lynx.bundle`

```tsx {10}
import { root } from "@lynx-js/react";

import "../common.css";

function App() {
  return (
    <view
      className="container"
      style={{
        clipPath: "circle(50% at 50% top)",
      }}
    >
    </view>
  );
}

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.11.0



### **ellipse**

 

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

**Entry:** `src/clip_path/ellipse`
**Bundle:** `dist/clip_path_ellipse.lynx.bundle`

```tsx {11}
import { root } from "@lynx-js/react";

import "../common.css";

function App() {
  return (
    <view
      className="container"
      style={{
        background: "linear-gradient(to bottom right, rgb(255,53,26), rgb(0,235,235) 50%)",
        clipPath: "ellipse(50px 60px at 10% 20%)",
      }}
    >
    </view>
  );
}

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.11.0



### **path**

 

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

**Entry:** `src/clip_path/path`
**Bundle:** `dist/clip_path_path.lynx.bundle`

```tsx {11,12}
import { root } from "@lynx-js/react";

import "../common.css";

function App() {
  return (
    <view
      className="container"
      style={{
        background: "linear-gradient(to right, rgb(255,53,26), rgb(0,235,235) 50%)",
        clipPath:
          "path('M36.9273 55.6337C35.2784 54.9693 33.3921 55.354 32.1351 56.611L31.9808 56.7653C30.3346 58.4116 27.6654 58.4116 26.0191 56.7653C24.803 55.5492 22.9701 55.1938 21.3876 55.8672C19.2453 56.7789 16.7696 55.7813 15.8579 53.639L15.7725 53.4383C15.0764 51.8026 13.4706 50.7408 11.6929 50.7408H11.4748C9.14659 50.7408 7.25919 48.8534 7.25919 46.5252C7.25919 44.8053 6.21441 43.2579 4.61919 42.6151C2.45972 41.745 1.41453 39.289 2.28469 37.1295L2.3662 36.9272C3.0306 35.2784 2.64593 33.3921 1.38892 32.1351L1.23471 31.9809C-0.411583 30.3346 -0.411564 27.6654 1.23473 26.0191C2.45085 24.803 2.80627 22.97 2.1328 21.3875C1.22113 19.2453 2.21872 16.7695 4.36099 15.8579L4.56168 15.7725C6.1974 15.0764 7.25919 13.4705 7.25919 11.6929V11.4747C7.25919 9.14657 9.14655 7.25922 11.4747 7.25922C13.1946 7.25922 14.742 6.21442 15.3848 4.61921C16.2549 2.45972 18.711 1.41448 20.8705 2.28466L21.0728 2.36618C22.7217 3.03059 24.6079 2.64592 25.8649 1.38891L26.0191 1.23471C27.6654 -0.411569 30.3346 -0.41157 31.9808 1.23471C33.197 2.45083 35.0299 2.80623 36.6124 2.13277C38.7547 1.22109 41.2305 2.21868 42.1422 4.36097L42.2276 4.5617C42.9237 6.19742 44.5295 7.25921 46.3072 7.25921H46.5253C48.8535 7.25921 50.7408 9.14656 50.7408 11.4747C50.7408 13.1946 51.7856 14.742 53.3808 15.3847C55.5402 16.2549 56.5854 18.7109 55.7153 20.8704L55.6337 21.0727C54.9693 22.7216 55.354 24.6079 56.611 25.8649L56.7653 26.0192C58.4116 27.6654 58.4116 30.3346 56.7653 31.9808C55.5492 33.1969 55.1938 35.0299 55.8672 36.6124C56.7789 38.7547 55.7813 41.2304 53.6391 42.1421L53.4384 42.2275C51.8026 42.9236 50.7408 44.5294 50.7408 46.3071V46.5252C50.7408 48.8534 48.8534 50.7408 46.5252 50.7408C44.8053 50.7408 43.2579 51.7856 42.6151 53.3808C41.745 55.5402 39.289 56.5854 37.1296 55.7153L36.9273 55.6337Z')",
      }}
    >
    </view>
  );
}

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.11.0



## Syntax

```css
/* Keyword values */
clip-path: none;

/* <basic-shape> values */
clip-path: inset(30px super-ellipse 3 3 50px/50px);
clip-path: circle(50px at 0 100px);
clip-path: ellipse(50px 60px at 10% 20%);
clip-path: path(
  'M0.5,1 C0.5,1,0,0.7,0,0.3 A0.25,0.25,1,1,1,0.5,0.3 A0.25,0.25,1,1,1,1,0.3 C1,0.7,0.5,1,0.5,1 Z'
);
```

### Values

The `clip-path` property is specified as one of the values listed below.

`none`

No clipping path is created.

`<basic-shape>`

A shape whose size and position is defined by its `border-box`. One of:

- `inset()`

Defines an inset rectangle.

```
inset( <length-percentage>{1, 4} [ round | (super-ellipse <exponents>) <border-radius>]?)

<length-percentage> =
  <length>
  <percentage>

<exponents> = <number>{2}

<border-radius> =
  <length-percentage [0,∞]>{1,4} [ / <length-percentage [0,∞]>{1,4} ]?
```

`<length-percentage>{1, 4}`

They represent the top, right, bottom, and left offsets from the `border-box` that defines the positions of the edges of the inset rectangle. These arguments follow the syntax of the margin shorthand, which let
you set all four insets with one, two or four values.

`round | (super-ellipse <exponents>) <border-radius>`

Optional arguments to define the rounded corners for the inset rectangle. When the shape is `round`, the corner radius acts like `<border-radius>`. When the shapes is `super-ellipse <exponent>`, the corner curve will be an [lame curve](https://en.wikipedia.org/wiki/Superellipse) 。`<border-radius>` using the border-radius shorthand syntax.

`<exponent>`

The two number are the exponents on the two dimensions, first is for x-axis and next for y-axis.

- `circle()`

Defines a circle using a radius and a position.

```
circle(<length-percentage> [at <position>]?)

<length-percentage> =
  <length [0,∞]>                |
  <percentage [0,∞]>

<position> =
  [ left | center | right | top | bottom | <length-percentage> ]  |
  [ left | center | right ] && [ top | center | bottom ]  |
  [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]  |
  [ [ left | right ] <length-percentage> ] && [ [ top | bottom ] <length-percentage> ]
```

`<length-percentage>`

This may be a `<length>`, or a `<percentage>` defining the radius of the circle.

`<position>`

Moves the center of the circle. May be a `<length>`, or a `<percentage>`, or a values such as `left`. The `<position>` value defaults to center if omitted.

- `ellipse()`

Defines an ellipse using two radii and a position.

An ellipse is essentially a squashed circle and so ellipse() acts in a very similar way to circle() except that we have to specify two radii x and y.

```
<ellipse()> =
  ellipse( <radial-size>? [ at <position> ]? )

<radial-size> =
  <length-percentage [0,∞]>{2}

<position> =
  [ left | center | right | top | bottom | <length-percentage> ]  |
  [ left | center | right ] && [ top | center | bottom ]  |
  [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]  |
  [ [ left | right ] <length-percentage> ] && [ [ top | bottom ] <length-percentage> ]

<length-percentage> =
  <length>      |
  <percentage>
```

`<radial-size>`

Two radii, x and y in that order. These may be a `<length>`, or a `<percentage>`.

`<position>`

Moves the center of the ellipse. May be a `<length>`, or a `<percentage>`, or a values such as left. The `<position>` value defaults to center if omitted.

- `path()`

Defines a shape using an SVG path definition.

```
  <path()> =
    path(<string> )
```

`path()`

The `path()` function takes [SVG path string](https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/d) as argument.

## Formal definition

| Initial value | none |
| Applies to | view |
| Inherited | no |
| Animatable | no |


## Differences from the Web

1. `inset()` function accepts `super-ellipse` as corner shape.
2. `polygon()` function is not supported.
3. `<clip-rule>` for `path()` function is not supported.

## Compatibility

**Compatibility Table**

**Query:** `css.properties.clip-path`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/193-clip-path.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| clip-path | Yes (2.13) | Yes (3.4) | Yes (2.13) | Yes (3.5) | Yes (3.5) | Yes |
| circle() | Yes (2.13) | Yes (3.4) | Yes (2.13) | Yes (3.5) | Yes (3.5) | Yes |
| inset() | Yes (2.13) | Yes (3.4) | Yes (2.13) | Yes (3.5) | Yes (3.5) | Yes |
| ellipse() | Yes (2.13) | Yes (3.4) | Yes (2.13) | Yes (3.5) | Yes (3.5) | Yes |
| path() | Yes (2.13) | Yes (3.4) | Yes (2.13) | Yes (3.5) | Yes (3.5) | Yes |
| polygon() | No | No | No | No | No | Yes |

**`clip-path`**

**Specifications:**
- [https://drafts.fxtf.org/css-masking/#the-clip-path](https://drafts.fxtf.org/css-masking/#the-clip-path)

