46 pre-built transitions!
Import the CSS and set an attribute on some HTML:
npm i transition-style
- import from CSS
- or import from JS
Individual Category Bundles
Import category bundles from NPM too
👉 The Hackpack
More options, more control, smaller import
by importing only the custom properties and base styles:
- compose custom transition combinations
- create multi-part transitions
- use classes or CSS-in-JS that leverage transition.css custom props
Custom properties ship with each
transition.css has been added to your project, add an attribute to an element and watch the magic:
A transitioned IN elementA transitioned OUT element
if nothing is happening when using the attributes, it's likely
transition.csshas not loaded
Attributes were chosen as the default so there's no question which transition is active. **There can be only 1 at a time.** With classes, for example, what happens when multiple "transition in" classes are applied to an element? Transition.css chooses to default with a state machine approach so things like a classname collision doesn't need solved. See the [custom](#custom) section below for ways to use classes and/or the shape custom properties so transition.css can fit into your development environment. The built in attribute based approach is very easy to hack, customize and escape.
Each bundle ships with the
@keyframes declared, and you can use them as you see fit. You can use these to build your own animations or just hook into the presets in your own way:
Checkout the src to find the names of the
@keyframe animations. They follow a pattern like the attributes, so you should be able to assume what they are with decent accuracy.
Using CSS Custom Properties
Each bundle ships with clearly named custom properties which contain the state and geometry needed to orchestrate custom transitions.
or target a specific transition and override it's defaults:
Go off the rails and build your own transitions with these variables. There's even the
The Hackpack which is exclusively the custom props 🤘💀 Here's how you can compose a brand new transition from the custom property primitives:
Then, in the HTML:
A custom transitioned element
The only rule is that you must transition from the same type of shapes
At this point you're using Transition.css to it's maximum. You can reach a huge set of transitions by using the custom properties. Have fun!
Play and experiment with this Codepen
npm run bundle concurrently bundles and minifies.