Theodore L.’s Post

You can animate elements without @keyframes. And honestly, this changes a lot. Most small UI animations do not need a full keyframe block. That is what @starting-style gives you. It lets you define the state an element should start from. Then CSS simply transitions to the normal state. So instead of building a full animation, you describe the end state once, and the browser handles the entry. That makes the code easier to read. And easier to tweak later. A simple example looks like this: .modal {  opacity: 1;  transform: translateY(0);  transition: opacity 0.25s ease, transform 0.25s ease;  @starting-style {   opacity: 0;   transform: translateY(20px);  } } This is great for small effects. But the really interesting part is somewhere else. Before @starting-style, CSS could not animate elements that had just entered the DOM. A tooltip appears. A dialog opens. A popover gets inserted. CSS had no real "before" state to animate from. So people used JavaScript tricks. @starting-style removes that mess. Now CSS can understand the starting point even for elements that were not visible a moment ago. That makes transitions feel much more natural for modals, dropdowns, tooltips, and anything dynamic. Support is already around 89%, so it is getting very usable. I really like this feature because it feels small, but it fixes a very old pain point. Have you tried @starting-style yet? *** If you want to build complex components using only HTML and CSS,   I wrote the ebook "You Don't Need JavaScript" to help you level up your CSS skills:   👉 https://lnkd.in/e9qjTXSA

  • Create new kind of animations thanks to the new @starting-style property in CSS

Absolutely, a great feature as it doesn't need JavaScript to launch the animation after ensuring that DOM is loaded...

I do love CSS and that's one of the reasons, its so powerful clean and easy to use 🤩

Very cool news! And 89% already, that surprised me!

Nice, this solves a very real pain. And also feels like we’re finally at the point where it’s usable in production.

Like
Reply

Best part is when you use it with elements that will be added on the dom and that removes entirely the need for JS to handle those type of things, one of the best features to come to CSS in a while, im using it all the time!

cool, CSS is nuts these days

Like
Reply
See more comments

To view or add a comment, sign in

Explore content categories