Transition classes are used to animate component states.
There are six classes applied for enter / leave transitions.
For this example, we’ll use the Collapse component, but this is applicable to other components as well.
We can change the class prefix using the data-ui-transition-name
attribute.
If you use Tailwind CSS, you can set animation classes via data attributes.
We provide ready-to-use classes for animation.
or can use animation classes in CSS.
or with Tailwind CSS.
If you are using the jolty-ui library, it already includes ready-to-use transitions
They can be used in two ways
By the data-ui-transition-name
attribute
or via js
All components support the following animation options.
Attribute | Type | Default | Description |
---|---|---|---|
transition | String, Boolean, TransitionOptions | true | Object with transition options or string to set the name option for the transition. |
enabled | String, Boolean, Function | 'auto' | Defines whether the module is enabled; when set to auto , it checks the media query (prefers-reduced-motion: no-preference) . Attribute: data-ui-transition-enabled |
name | String | 'ui' | Defines the name of the transition that will be used to apply CSS rules. Attribute: data-ui-transition-name |
css | Boolean | true | Defines if the transition should be applied using CSS rules. |
cssVariables | Boolean | false | Adds special CSS variables during the transition to the element and removes them after completion. |
enter | Function | null | Accepts a function enter(el, done){} . call the done() callback to indicate transition end |
enterActive | String, Object | '' | CSS classes or styles applied during the entire entering phase. Attribute: data-ui-enter-active |
enterFrom | String, Object | '' | CSS classes or styles applied at the start of the entering phase. Attribute: data-ui-enter-from |
enterTo | String, Object | '' | CSS classes or styles applied at the end of the entering phase. Attribute: data-ui-enter-to |
leave | Function | null | Accepts a function leave(el, done){} . call the done() callback to indicate transition end |
leaveActive | String, Object | '' | CSS classes or styles applied during the entire leaving phase. Attribute: data-ui-leave-active |
leaveFrom | String, Object | '' | CSS classes or styles applied at the start of the leaving phase. Attribute: data-ui-leave-from |
leaveTo | String, Object | '' | CSS classes or styles applied at the end of the leaving phase. Attribute: data-ui-leave-to |
duration | Number | null | Defines the duration of the transition. Should be used only when the animation occurs on child elements. |
If the cssVariables
option is enabled, special CSS variables are added during the transition to the element and are removed after its completion.
Name | Type | Description |
---|---|---|
--ui-transition-width | Number | The width of the element at the start of the transition. |
--ui-transition-height | Number | The height of the element at the start of the transition. |