Presence
Keeps content on the page until its closing animation ends.
Usage
import { Presence } from '@leverui/components';
<Presence present={true}>
<div>Presence content</div>
</Presence>
Keeps an element in the page while its CSS entry and exit animations run.
present: boolean. Whether the element is shown.[data-state='open']: styles the open state.[data-state='closed']: styles the closed state.
Examples
Fade
Setting the animation name to fade-in and fade-out, the component will animate the entry and exit of the element.
Scale Fade
Using the animation names scale-in and fade-in, then scale-out and fade-out, the component will animate the entry and exit of the element.
Slide Fade
Here's an example that uses the animation names slide-from-bottom and slide-to-bottom to animate the entry and exit of the element.
Slide
Here's an example that uses the animation names slide-from-bottom-full and slide-to-bottom-full to animate the entry and exit of the element.
Lazy Mount
Use the lazyMount prop to delay the mount of the component until it's present.
Unmount On Exit
Use the unmountOnExit prop to unmount the component when it's not present.
Customize with CSS
Always has the .leverui-presence class and sets data-state to "open" or
"closed". Presence animates nothing by itself. Add your own class and
animation rules, and respect the reduced-motion setting.
@keyframes details-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes details-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.details-presence[data-state='open'] {
animation: details-in 200ms both;
}
.details-presence[data-state='closed'] {
animation: details-out 200ms both;
}
@media (prefers-reduced-motion: reduce) {
.details-presence {
animation: none;
}
}
The button that shows and hides the element sets its own expanded state.
Presence adds no dialog roles and does not manage focus. Use class and style
for one-off styling. No CSS objects or style shorthand props.