--- url: "https://web.dev/blog/baseline-entry-animations" titulek: "Now in Baseline: animating entry effects | Blog | web.dev" h1: "Now in Baseline: animating entry effects Stay organized with collections Save and categorize content based on your preferences." popis: "Improve the legibility of text when using fallback fonts." jazyk: "en" kanonicka: "https://web.dev/blog/baseline-entry-animations" drobecky: ["Blog", "Now in Baseline: animating entry effects"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 02:41:10" znaku: 5811 slov: 786 kodovani: "iso-8859-2" sha256: "54d9fbf58e5ef0f5770a3102af2a2d57dcee829f04693d6cd796a0eacba595a2" --- Now in Baseline: animating entry effects Stay organized with collections Save and categorize content based on your preferences. Published: August 8, 2024 Una Kravets The post [four new CSS features for entry and exit effects](https://developer.chrome.com/blog/entry-exit-animations) shared some useful features that had just landed in Chrome. Now, two of these features, [@starting-style](https://developer.mozilla.org/docs/Web/CSS/@starting-style) and [transition-behavior: allow-discrete](https://developer.mozilla.org/docs/Web/CSS/transition-behavior) have become Baseline Newly available with the release of Firefox 129. You can now create entry animation effects for elements, including those animating from `display: none`, and animating into the top layer. Setting up entry effects with `@starting-style` Browser Support 117 117 129 17.5 [Source](https://developer.mozilla.org/docs/Web/CSS/Reference/At-rules/@starting-style) The `@starting-style` rule defines the initial styles on an element before it's rendered on the page. This is required for elements that animate in from `display: none`, as they need a state from which to animate in. Use `@starting-style` like any other at-rule in CSS, by placing the element's styles within it. For example, with a ``, place the `dialog[open]` styles within a `@starting-style` rule. These are the styles used before the dialog opens. `@starting-style { dialog[open] { /* Styles before the dialog opens */ } }` Enabling discrete animations with `allow-discrete` Browser Support 117 117 129 17.4 [Source](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/transition-behavior) The second thing needed to support entry animations for elements which animate from `display: none`, such as dialogs and popovers, is to enable a new animation mode, to support the animation of [discrete properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties#discrete). Discrete properties are those that can't interpolate between values. You can think of these like an on/off switch. Some examples include `display`, `visibility`, `mix-blend-mode`—any property where the feature is one value or another. With this new animation mode, the browser now supports swapping the values at the 50% point instead of at the 0% point of a transition. Use one of the following two ways to animate entry effects for `display: none` and `visibility: hidden` elements: The standalone property `transition-behavior` with the value `allow-discrete`. The `allow-discrete` value in your transition shorthand. We recommend the second method, because applying `transition-behavior` is included in the `transition` shorthand. If you apply `transition-behavior: allow-discrete` *before* the transition shorthand where you are applying the transition, timing, and easing functions, the browser will ignore the `transition-behavior`. If using this in the shorthand, you only need to apply the `allow-discrete` keyword to the specific properties which require discrete animations. This is demonstrated in the following CSS which transitions both the `translate` property and the `display` property, but only applies the `allow-discrete` keyword to the `display` property. `transition: translate 0.7s ease-out, display 0.7s ease-out allow-discrete;` Demo: putting it all together Using these features is particularly useful for top-layer elements, such as the [``](https://developer.mozilla.org/docs/Web/HTML/Element/dialog) element or components that use the [`popover`](https://developer.mozilla.org/%20docs/Web/HTML/Global_attributes/popover) attribute. In the following example, a `` element is animated from the bottom of the viewport (initially starting at a 100vh vertical translation off-screen), to the center of the viewport, removing the translation when the `` is open. `/* Before the dialog opens */ @starting-style { dialog[open] { translate: 0 100vh; } } /* Dialog is-open state */ dialog[open] { translate: 0 0; transition: translate 0.7s ease-out, display 0.7s ease-out allow-discrete; }` You can write this more concisely with CSS nesting, which is also a Baseline newly available feature. Browser Support 120 120 117 17.2 [Source](https://developer.mozilla.org/docs/Web/CSS/Reference/Selectors/Nesting_selector) `dialog[open] { translate: 0 0; transition: translate 0.7s ease-out, display 0.7s ease-out allow-discrete; @starting-style { translate: 0 100vh; } }` Demo animating in a dialog element. Conclusion It's exciting to see progress like this land in Baseline, and at the very least, it is a nice progressive enhancement for those elements. Without these entry effect features, the elements that are animating into the top layer or from a `display: none` style will simply appear on your page without the transition, as they do today. To learn how to add exit effects in a progressively enhanced way, check out the article [“Four new CSS features for smooth entry and exit animations”](https://developer.chrome.com/blog/entry-exit-animations), and to learn more about these features, check out the following documentation resources: [@starting-style on MDN](https://developer.mozilla.org/docs/Web/CSS/@starting-style) [transition-behavior on MDN](https://developer.mozilla.org/docs/Web/CSS/transition-behavior) Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates. Last updated 2024-08-08 UTC.