This is considered an experimental feature.
Imba has support for transitioning when elements are added to and removed from
the document. If you set an
Imba does not ship with any prebuilt transitions. This might change in a later version, but the idea is that the syntax for styling is powerful enough to easily create your own transitions.
import 'util/styles'
css label d:hflex ja:center us:none
css input mx:1
tag App
alerted = no
<self @click=(alerted = !alerted)>
if alerted
<div.alert> "Important message"
let app = imba.mount <App.clickable>
In the above example, we attach the
# css div p:2 m:2 overflow:hidden min-width:80px
import 'util/styles'
tag App
alerted = no
<self @click=(alerted = !alerted)>
if alerted
<div.alert[opacity@off:0] ease> "Important message"
let app = imba.mount <App.clickable>
Now that we have declared that this element should ease, we use the
If you want separate transitions depending on whether the element is being attached or detached, you can use the
# css div p:2 m:2 overflow:hidden min-width:80px
import 'util/styles'
tag App
alerted = no
<self @click=(alerted = !alerted)>
if alerted
<div.alert[y@in:100px y@out:-100px] ease> "In from below, out above!"
let app = imba.mount <App.clickable>
Now you can see that it comes in from the left, but leaves to the right. If the element is re-attached while exiting or detached while still entering, the transition will gracefully revert. You can see this by clicking the checkbox rapidly.
You can easily transition nested elements inside the eased element as well.
# css div p:2 m:2 overflow:hidden min-width:80px
import 'util/styles'
tag App
alerted = no
<self @click=(alerted = !alerted)>
if alerted
<div.alert[o@off:0 y@off:100px ease:1s] ease>
<div[scale@off:0]> "Important message"
let app = imba.mount <App.clickable>
Click to see the inner div scale during the transition. Also note that we did set the duration of the transition using the