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

# perspective

APISummary
## Introduction

The perspective CSS property determines the distance between the z=0 plane and the user in order to give a 3D-positioned element some perspective.

## Examples

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

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

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

const Perspective = () => {
  const [front, setFront] = useState(false);
  const [enableAni, setEnableAni] = useState(false);

  const handleKeyframe = () => {
    setFront(!front);
  };

  const handleAni = () => {
    setEnableAni(!enableAni);
  };

  const containerStyle = {
    display: "flex" as const,
    flexDirection: "column" as const,
    width: "100%",
    height: "1000px",
    background: "white",
  };

  const perspectiveStyle = {
    perspective: "750px",
  };

  return (
    <view style={containerStyle}>
      <text>Animation demo</text>

      <view className={front ? "container front" : "container back"} style={perspectiveStyle} bindtap={handleKeyframe}>
        <text>Front</text>
      </view>
      <view
        className={front ? "container1 back" : "container1 front"}
        style={perspectiveStyle}
        bindtap={handleKeyframe}
      >
        <view className="container2" />
        <text>Back</text>
      </view>
      <view className="anim-container">
        <view
          className={enableAni ? "anim-content anim-content-back backf0" : "anim-content anim-content-back backf1"}
          style={perspectiveStyle}
          bindtap={handleAni}
        >
          <text>Front</text>
          <text>Back</text>
        </view>
        <view
          className={enableAni ? "anim-content anim-content-front keyf0" : "anim-content anim-content-front keyf1"}
          style={perspectiveStyle}
          bindtap={handleAni}
        >
          <text>back</text>
        </view>
      </view>
    </view>
  );
};

root.render(<Perspective />);

```

v0.11.0



## Syntax

```css
/* Keyword value */
perspective: auto;

/* <length> values */
perspective: 20px;
perspective: 3.5em;
```

### Values

- `auto`
  Default value

- `[<length>]`
  specifies the observer's distance from the `z=0` plane

```
perspective = auto | <length [0,∞]>
```

## Formal definition

| Initial value | empty value |
| Applies to | all elements |
| Inherited | no |
| Animatable | no |


## Formal syntax

```
perspective = auto | <length [0,∞]>
```

## Differences from the Web

- Different from Web, the Perspective property in Lynx takes effect on the current node, while in Web, the Perspective property takes effect on child nodes.

## Compatibility

**Compatibility Table**

**Query:** `css.properties.perspective`

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

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

**`perspective`**

**Specifications:**

- **Web — Supported (version unknown):** It takes effect on all its descendants.

