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

# animation

APISummary
## Introduction

The animation property is a shorthand property for [animation-name](/next/api/css/properties/animation-name.md), [animation-duration](/next/api/css/properties/animation-duration.md), [animation-timing-function](/next/api/css/properties/animation-timing-function.md), [animation-delay](/next/api/css/properties/animation-delay.md), [animation-iteration-count](/next/api/css/properties/animation-iteration-count.md), [animation-direction](/next/api/css/properties/animation-direction.md), [animation-fill-mode](/next/api/css/properties/animation-fill-mode.md), and [animation-play-state](/next/api/css/properties/animation-play-state.md).

## Examples

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

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

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

const Keyframes = () => {
  const [flag, setFlag] = useState(true);

  const transProperties = ["translateX", "translateY", "translateXY"];
  const rotateProperties = ["rotateZ", "rotateX", "rotateY"];
  const scaleProperties = ["scaleX", "scaleY", "scaleXY"];
  const flipProperties = ["flipX", "flipY", "flipXY"];
  const otherProperties = ["background-color", "opacity"];

  const containerHeightStyle = {
    height: "200rpx",
  };

  const columnWidthStyle = {
    width: "250rpx",
  };

  const rotateHeightStyle = {
    height: "150rpx",
  };

  const scaleImageStyle = {
    marginLeft: "15px",
    marginTop: "30px",
  };

  const otherStyle = {
    marginLeft: "15px",
    marginTop: "15px",
  };

  const getAnimationStyle = (name: string) => ({
    animation: `${name}-ani 2s ease 0s infinite alternate both running` as const,
  });

  return (
    <scroll-view scroll-orientation="vertical" className="fd-col container">
      <text className="h1">keyframes animation</text>
      <view className="sep"></view>
      <view className="fd-col group pd5">
        <text className="button h2">translate animation</text>
        <view className="fd-row" style={containerHeightStyle}>
          {transProperties.map((item, index) => (
            <view style={columnWidthStyle} key={`trans-${index}`} className="fd-col mg5">
              <text className="h3 mgl15">{item}</text>
              <image style={getAnimationStyle(item)} className="ani-size mg5 mgl15 mgt15" src={lynxImage} />
            </view>
          ))}
        </view>
      </view>
      <view className="sep"></view>

      <view className="fd-col group pd5">
        <text className="button h2">rotate animation</text>
        <view className="fd-row" style={rotateHeightStyle}>
          {rotateProperties.map((item, index) => (
            <view style={columnWidthStyle} key={`rotate-${index}`} className="fd-col mg5">
              <text className="h3 mgl15">{item}</text>
              <image style={getAnimationStyle(item)} className="ani-size mg5 mgl15 mgt15" src={lynxImage} />
            </view>
          ))}
        </view>
      </view>
      <view className="sep"></view>

      <view className="fd-col group pd5">
        <text className="button h2">scale animation</text>
        <view className="fd-row" style={containerHeightStyle}>
          {scaleProperties.map((item, index) => (
            <view style={columnWidthStyle} key={`scale-${index}`} className="fd-col mg5">
              <text className="h3 mgl15">{item}</text>
              <image style={{ ...getAnimationStyle(item), ...scaleImageStyle }} className="ani-size" src={lynxImage} />
            </view>
          ))}
        </view>
      </view>
      <view className="sep"></view>

      <view className="fd-col group pd5">
        <text className="button h2">flip animation</text>
        <view className="fd-row" style={containerHeightStyle}>
          {flipProperties.map((item, index) => (
            <view style={columnWidthStyle} key={`flip-${index}`} className="fd-col mg5">
              <text className="h3 mgl15">{item}</text>
              <image style={getAnimationStyle(item)} className="ani-size mg5 mgl15 mgt15" src={lynxImage} />
            </view>
          ))}
        </view>
      </view>
      <view className="sep"></view>

      <view className="fd-col group pd5">
        <text className="button h2">bg-color opacity animation</text>
        <view className="fd-row" style={containerHeightStyle}>
          {otherProperties.map((item, index) => (
            <view style={columnWidthStyle} key={`other-${index}`} className="fd-col mg5">
              <text className="h4 mgl15">{item}</text>
              <view className="base"></view>
              <view
                style={{
                  animation: `${item}-ani 2s ease 0s infinite alternate both ${flag ? "running" : "paused"}`,
                  ...otherStyle,
                }}
                className="ani-size"
              />
            </view>
          ))}
        </view>
      </view>
      <view className="sep"></view>
    </scroll-view>
  );
};

root.render(<Keyframes />);

```

v0.11.0



## Syntax

```css
/* @keyframes name | duration | timing-function | delay |
   iteration-count | direction | fill-mode | play-state*/
animation: slidein 3s ease-in 1s 2 reverse both paused;

/* @keyframes name | duration | timing-function | delay */
animation: slidein 3s linear 1s;

/* @keyframes name | duration */
animation: slidein 3s;

/* Multiple animations */
animation:
  slidein 3s ease-in 1s 2 reverse both paused,
  ani_scale 3s linear 1s;
```

## Caution

:::caution

- When writing CSS `@keyframes`, it is recommended not to omit the values for the `0%` (or `from`) stage and `100%` (or `to`) stage. If the start and end stage values are not specified, we will use the node's current property value. Due to system limitations, the transform property on Android systems may have issues.

:::

## Formal definition

| Initial value | animation-name: none
animation-duration: 0s
animation-timing-function: ease
animation-delay: 0s
animation-iteration-count: 1
animation-direction: normal
animation-fill-mode: none
animation-play-state: running |
| Applies to | all elements |
| Inherited | no |
| Animatable | no |


## Formal syntax

Animation can specify multiple sets of animations. Properties within each set of animations are separated by spaces, and sets of animations are separated by commas.

```
animation: <animation-name> || <animation-duration> ||
  <animation-timing-function> || <animation-delay> ||
  <animation-iteration-count> || <animation-direction> || <animation-fill-mode>
  || <animation-play-state>;
```

## Animation events

- [Animation Event](/next/api/lynx-api/event/animation-event.md)

## See also

- [animation](/next/api/css/properties/animation.md)
- [animation-name](/next/api/css/properties/animation-name.md)
- [animation-duration](/next/api/css/properties/animation-duration.md)
- [animation-timing-function](/next/api/css/properties/animation-timing-function.md)
- [animation-delay](/next/api/css/properties/animation-delay.md)
- [animation-iteration-count](/next/api/css/properties/animation-iteration-count.md)
- [animation-direction](/next/api/css/properties/animation-direction.md)
- [animation-fill-mode](/next/api/css/properties/animation-fill-mode.md)
- [animation-play-state](/next/api/css/properties/animation-play-state.md)
- [CSS animation event](/next/api/lynx-api/event/animation-event.md)
- [Animated API](/next/api/lynx-api/lynx/lynx-animate-api.md)

## Compatibility

**Compatibility Table**

**Query:** `css.properties.animation`

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

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

**`animation`**

**Specifications:**

