Open reboottime opened 1 year ago
For example
.notification {
background: red;
height: 24px;
width: 100px;
transition: background-color ease .2s;
}
.notification.warning {
background-color: yellow;
}
Transition
componentThe Transition
component in Mantine UI
serves as a wrapper
that generates and applies transition styles to its child.
binds event listeners on different transition stages, such as onEnter
, onExit
, onEntered
, etc.
The Transition component acts as a wrapper and does not have an associated HTML element itself. So there is no way to attach JavaScript event listeners on itself at all.
define transition triggering via the mounted
property
Here's an example code snippet that demonstrates the usage of the Transition
component:
<Transition mounted={opened} transition={scaleY} duration={200} timingFunction="ease">
{(styles) => (
<Paper
shadow="md"
style={{ ...styles, position: 'absolute', top: 0, left: 0, right: 0, height: rem(120) }}
ref={clickOutsideRef}
>
Dropdown
</Paper>
)}
</Transition>
As you see above, the child(only one direct child) of the Transition
component is implemented as a function. .
mounted
property: the transition is triggered once the mounted
is true, so the transition passed to Transition
needs to define both the in
(mounted is true) and out
(mounted is false) about what the values will be for these transitionable properties.
Overview
This React daily article discusses the design of the Transition component in Mantine UI, and its rationales - CSS3 transitions and corresponding JavaScript events.