diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 79c0b19..b887482 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -4,7 +4,6 @@ on:
push:
branches: [main]
pull_request:
- branches: [main]
jobs:
build:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 511ccc7..9eecf74 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
+- Add opt-in `animations: true` support for direction-specific logical keyframes and static `animation`/`animation-name` references, including prefixed definitions, name collisions and conditional same-name definitions. Preserve original definitions and warn for dynamic references.
+
- Transform logical names in `transition-property`, keeping static duration, delay, timing-function and behavior lists aligned when a property expands into several physical names. Dynamic or inherited timing lists are retained with a warning when expansion cannot be safely aligned.
## [0.7.0] - 2026-10-03
diff --git a/README.md b/README.md
index 36ebb6e..ed04827 100644
--- a/README.md
+++ b/README.md
@@ -17,8 +17,8 @@ Use this plugin when your internationalized application needs both directions in
| Your target browsers support the logical properties you use | Native CSS; no transformation is needed |
| Compile logical properties for one configured direction or writing mode | [postcss-logical](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-logical), also available through [postcss-preset-env](https://github.com/csstools/postcss-plugins/tree/main/plugin-packs/postcss-preset-env) |
| Mirror existing physical LTR styles into RTL styles | [RTLCSS](https://github.com/MohammadYounes/rtlcss) or [postcss-rtlcss](https://github.com/elchininet/postcss-rtlcss) |
-| Compile logical properties into one stylesheet with horizontal LTR/RTL scopes, including existing direction selectors | **postcss-logical-polyfill** |
-| Need logical-property transformations for vertical writing modes or keyframes | Evaluate [postcss-logical-properties-polyfill](https://github.com/erickskrauch/postcss-logical-properties-polyfill), whose documentation lists these features |
+| Compile logical properties into one stylesheet with horizontal LTR/RTL scopes, including existing direction selectors and opt-in logical animations | **postcss-logical-polyfill** |
+| Need logical-property transformations for vertical writing modes | Evaluate [postcss-logical-properties-polyfill](https://github.com/erickskrauch/postcss-logical-properties-polyfill), whose documentation lists these features |
Other tools also generate combined LTR/RTL styles. This plugin focuses on logical-property input, existing direction scopes, common declarations and additional logical values. Check the [supported properties](https://github.com/oe/postcss-logical-polyfill/blob/main/docs/src/content/docs/references/supported-properties.mdx) and limitations below against your application.
@@ -150,10 +150,33 @@ These classes must match ancestors of the styled elements. They scope the genera
See the [configuration guide](https://github.com/oe/postcss-logical-polyfill/blob/main/docs/src/content/docs/guides/configuration.mdx) for selector lists and integration options.
+## Logical keyframes (opt-in)
+
+```js
+logicalPolyfill({ animations: true });
+```
+
+The plugin keeps original keyframes and creates LTR/RTL physical-property copies for referenced logical animations. Both `animation-name` and `animation` shorthand references are rewritten. Ordinary animations are unchanged. Generated names avoid existing definitions and static references; same-name definitions retain their original media/supports/layer contexts.
+
+```css
+/* Input */
+@keyframes slide {
+ from { margin-inline-start: 0; }
+ to { margin-inline-start: 100px; }
+}
+.card { animation: slide 1s linear; }
+```
+
+This generates direction-specific `lp-slide-ltr` and `lp-slide-rtl` keyframes and matching animation rules. Generated names may gain a numeric suffix when needed to avoid collisions.
+
+Try the [runnable animation example](https://github.com/oe/postcss-logical-polyfill/tree/main/examples/logical-animations).
+
+Run `postcss-import` before this plugin when definitions and references are in separate files. Runtime names inside `var()` or `env()` cannot be resolved reliably: they remain unchanged with a PostCSS warning, and original definitions remain available for browsers with native logical-property support. They do not gain a physical-property animation fallback. Expand CSS nesting before the plugin.
+
## Compatibility and limitations
- Transformations assume horizontal writing modes. Vertical writing modes are not inferred.
-- Keyframes and certain other at-rules are left untouched. Logical property names in `transition` and `transition-property` are transformed; animation names and keyframe contents are not rewritten.
+- Keyframes are left untouched by default. Enable `animations: true` to transform referenced logical keyframes and static animation names. Logical property names in `transition` and `transition-property` are transformed independently of this option.
- Expand CSS nesting before this plugin, using a tool such as `postcss-nested` or `postcss-nesting`. Unexpanded nested rules are left intact with a PostCSS warning.
- Direction prefixes add selector specificity. Overrides in separate rules should use matching direction scopes. For subtrees with conflicting direction ancestors, write explicit direction-scoped selectors so the plugin can use the rightmost context.
- Repeated physical properties within an optimized rule are resolved by `!important` priority, then source order. Overlapping common shorthands are retained in direction rules where needed to preserve their ordering relative to directional longhands.
diff --git a/docs/src/content/docs/getting-started/introduction.mdx b/docs/src/content/docs/getting-started/introduction.mdx
index 23347b9..73ebe38 100644
--- a/docs/src/content/docs/getting-started/introduction.mdx
+++ b/docs/src/content/docs/getting-started/introduction.mdx
@@ -21,7 +21,7 @@ Other tools also generate combined LTR/RTL styles. This plugin focuses on logica
## Compatibility
-The plugin assumes horizontal writing modes. It transforms logical property names in `transition`, but leaves keyframe contents and animation names untouched. Expand CSS nesting before running the plugin.
+The plugin assumes horizontal writing modes. It transforms logical property names in `transition` and `transition-property`. Keyframes and animation references are left untouched by default; enable `animations: true` to compile static references to logical keyframes. Expand CSS nesting before running the plugin.
Generated direction prefixes add specificity. Use matching scopes for overrides in separate rules and explicit direction-scoped selectors for subtrees with conflicting direction ancestors.
diff --git a/docs/src/content/docs/guides/configuration.mdx b/docs/src/content/docs/guides/configuration.mdx
index d9b587a..7a9530b 100644
--- a/docs/src/content/docs/guides/configuration.mdx
+++ b/docs/src/content/docs/guides/configuration.mdx
@@ -377,3 +377,15 @@ console.log('Transformed CSS:', result.css);
### From Other Logical Property Tools
Like `postcss-logical`, this plugin converts logical properties to physical properties. It generates both horizontal LTR and RTL scopes in one stylesheet, rather than mapping all declarations for one configured direction. Review the generated selectors, specificity and supported properties when migrating.
+
+## Logical keyframes
+
+Enable animation compilation explicitly:
+
+```js
+logicalPolyfill({ animations: true });
+```
+
+The default is `false`. Referenced logical keyframes receive separate physical-property copies for LTR and RTL, with collision-free generated names. Static `animation-name` and `animation` shorthand references use the matching direction copy. Original definitions remain available. Duplicate names in conditional rules retain those conditions.
+
+Definitions and references must be available in the same PostCSS root; run `postcss-import` first for multi-file animations. Expand CSS nesting first. Dynamic names in `var()`/`env()` remain unchanged with a warning and do not receive an old-browser fallback.
diff --git a/docs/src/content/docs/references/api.mdx b/docs/src/content/docs/references/api.mdx
index 9206a13..9e03d09 100644
--- a/docs/src/content/docs/references/api.mdx
+++ b/docs/src/content/docs/references/api.mdx
@@ -446,9 +446,9 @@ The plugin includes TypeScript definitions:
```typescript
import postcss from 'postcss'
-import logicalPolyfill, { Options } from 'postcss-logical-polyfill'
+import logicalPolyfill, { LogicalPolyfillOptions } from 'postcss-logical-polyfill'
-const options: Options = {
+const options: LogicalPolyfillOptions = {
preserve: false,
dir: 'ltr',
supports: true,
@@ -482,3 +482,7 @@ For large projects, consider:
1. Using `preserve: false` in production
2. Enabling `supports: true` for progressive enhancement
3. Processing only relevant CSS files
+
+## Animation compilation
+
+`animations?: boolean` enables logical keyframe and static animation-reference compilation. Its default is `false`. Existing direction selectors and `outputOrder` also apply to the generated animation rules. See the [configuration guide](../../guides/configuration/#logical-keyframes) for limitations.
diff --git a/examples/README.md b/examples/README.md
index 4a36e6e..728fcfe 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -49,3 +49,7 @@ Or run individual examples by navigating to their directories and following the
- Nested selectors with logical properties
- Complex scenarios with both RTL and LTR rules
- Difference between scoped and unscoped logical properties
+
+## Logical animations
+
+[Logical keyframes](./logical-animations/) demonstrates opt-in animation compilation and a browser direction toggle.
diff --git a/examples/logical-animations/README.md b/examples/logical-animations/README.md
new file mode 100644
index 0000000..089e41e
--- /dev/null
+++ b/examples/logical-animations/README.md
@@ -0,0 +1,11 @@
+# Logical keyframes
+
+After installing repository dependencies, run from this directory:
+
+```sh
+pnpm exec tsx process.ts
+```
+
+Open `index.html` in a browser. The generated `output.css` contains separate LTR and RTL keyframes. Switching the root `dir` attribute changes the active animation without rebuilding CSS.
+
+Animation compilation requires `animations: true`; the default remains disabled. This example keeps definitions and static references in one file. For separate files, inline them with `postcss-import` first. Runtime references through `var()` remain native-only and produce a warning.
diff --git a/examples/logical-animations/index.html b/examples/logical-animations/index.html
new file mode 100644
index 0000000..0f98b52
--- /dev/null
+++ b/examples/logical-animations/index.html
@@ -0,0 +1,23 @@
+
+
+
+
+
+ Logical keyframes: LTR and RTL
+
+
+
+
One stylesheet, two animation directions
+
+
The box moves away from the start edge in both directions.