> 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-fill-mode

APISummary
## Introduction

`animation-fill-mode` property sets how a CSS animation applies styles to its target before and after its execution.

## Examples

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

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

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

const AnimationFillMode = () => {
  const noneProperties = ["none"];
  const forwardsProperties = ["forwards"];
  const backwardsProperties = ["backwards"];
  const bothProperties = ["both"];

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

  const columnStyle = {
    width: "350px",
  };

  const getAnimationStyle = (fillMode: string) => ({
    animation: `ani 3s ease 2s 1 normal ${fillMode} running` as const,
  });

  return (
    <scroll-view scroll-orientation="vertical" className="fd-col container">
      <text className="h1">keyframes animation demo: fillmode</text>
      <text className="h4">From--&gt; transform: translateX(50px);background-color: blue;</text>
      <text className="h4">To--&gt; transform: translateX(200px);background-color: red;</text>
      <view className="sep"></view>

      <view className="fd-col group pd5">
        <text className="button h2">none</text>
        <view className="fd-row" style={containerStyle}>
          {noneProperties.map(item => (
            <view style={columnStyle} className="fd-col mg5" key={item}>
              <text className="h4 mgl15">{item}</text>
              <view flatten={false} style={getAnimationStyle(item)} className="ani-size mg5" />
            </view>
          ))}
        </view>
      </view>
      <view className="sep"></view>

      <view className="fd-col group pd5">
        <text className="button h2">forwards</text>
        <view className="fd-row" style={containerStyle}>
          {forwardsProperties.map(item => (
            <view style={columnStyle} className="fd-col mg5" key={item}>
              <text className="h4 mgl15">{item}</text>
              <view flatten={false} style={getAnimationStyle(item)} className="ani-size mg5" />
            </view>
          ))}
        </view>
      </view>
      <view className="sep"></view>

      <view className="fd-col group pd5">
        <text className="button h2">backwards</text>
        <view className="fd-row" style={containerStyle}>
          {backwardsProperties.map(item => (
            <view style={columnStyle} className="fd-col mg5" key={item}>
              <text className="h4 mgl15">{item}</text>
              <view flatten={false} style={getAnimationStyle(item)} className="ani-size mg5" />
            </view>
          ))}
        </view>
      </view>
      <view className="sep"></view>

      <view className="fd-col group pd5">
        <text className="button h2">both</text>
        <view className="fd-row" style={containerStyle}>
          {bothProperties.map(item => (
            <view style={columnStyle} className="fd-col mg5" key={item}>
              <text className="h4 mgl15">{item}</text>
              <view flatten={false} style={getAnimationStyle(item)} className="ani-size mg5" />
            </view>
          ))}
        </view>
      </view>
      <view className="sep"></view>
    </scroll-view>
  );
};

root.render(<AnimationFillMode />);

```

v0.11.0



## Syntax

```css
/* Single animation */
animation-fill-mode: none;
animation-fill-mode: forwards;
animation-fill-mode: backwards;
animation-fill-mode: both;

/* Multiple animations */
animation-fill-mode: none, backwards;
animation-fill-mode: both, forwards, none;
```

### Values

#### none

**Default value**. The animation will not apply any styles to the target when it's not executing. The element will display using the CSS rules that have already been applied to it. This is the default value.

#### forwards

The target will retain the computed values set by the last keyframe encountered during execution. The last keyframe depends on the values of [animation-direction](/next/api/css/properties/animation-direction.md) and [animation-iteration-count](/next/api/css/properties/animation-iteration-count.md):

| animation-direction | animation-iteration-count | last keyframe encountered |
| ------------------- | ------------------------- | ------------------------- |
| normal              | even or odd               | 100% or to                |
| reverse             | even or odd               | 0% or from                |
| alternate           | even                      | 0% or from                |
| alternate           | odd                       | 100% or to                |
| alternate-reverse   | even                      | 100% or to                |
| alternate-reverse   | odd                       | 0% or from                |

#### backwards

The animation will apply the values defined in the first keyframe at the start of the animation. The first keyframe depends on the value of [animation-direction](/next/api/css/properties/animation-direction.md):

| animation-direction          | first relevant keyframe |
| ---------------------------- | ----------------------- |
| normal or alternate          | 0% or from              |
| reverse or alternate-reverse | 100% or to              |

#### both

The animation will follow both the forwards and backwards rules, applying the keyframe values both before and after the animation.

## Formal definition

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


## Formal syntax

```css
/*none*/
animation-fill-mode: none | forwards | backwards | both;
```

## 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-fill-mode`

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

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

**`animation-fill-mode`**

**Specifications:**

