Overlays@knitui/components
Transition
Transition drives single-child mount/unmount animations via a render prop. It mirrors Mantine's Transition API: the mounted prop controls visibility, transition selects the preset, and the render prop receives computed style that the child spreads onto any element. Respects the user's reduced-motion preference.
import { Transition } from "@knitui/components";Playground
Loading playground…
<Transition
mounted
transition="fade"
duration={250}
timingFunction="ease"
keepMounted={false}
/>Examples
Controlled
Toggle mounted on and off to watch the animation play.
Loading example…
All Presets
Every built-in transition preset side by side — click Show/Hide to compare.
Loading example…
Keep Mounted
keepMounted keeps the child in the DOM (display:none) instead of unmounting it.
Loading example…
With Delays
Enter and exit delays let you stagger reveals — useful for sequential animations.
Loading example…
Slow Motion
Slow duration makes it easy to observe the transition in detail.
Loading example…
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children required | (styles: TransitionStyle) => ReactElement | — | Render function that receives the computed transition styles. |
mounted required | boolean | true | Whether the child should be visible/mounted. |
duration | number | undefined | 250 | Enter transition duration in ms. |
enterDelay | number | undefined | — | Delay in ms before the enter transition starts. |
exitDelay | number | undefined | — | Delay in ms before the exit transition starts. |
exitDuration | number | undefined | duration | Exit transition duration in ms (defaults to `duration`). |
keepMounted | boolean | undefined | false | When true the child stays in the DOM with `display:none` after exiting rather than being unmounted. |
onEnter | (() => void) | undefined | — | Called when the enter transition starts. |
onEntered | (() => void) | undefined | — | Called when the enter transition ends. |
onExit | (() => void) | undefined | — | Called when the exit transition starts. |
onExited | (() => void) | undefined | — | Called when the exit transition ends. |
timingFunction | string | undefinedease · ease-in · ease-out · ease-in-out · linear | "ease" | CSS transition timing function. |
transition | MantineTransition | undefinedfade · fade-up · fade-down · fade-left · fade-right · scale · scale-y · scale-x · skew-up · skew-down · rotate-left · rotate-right · slide-down · slide-up · slide-left · slide-right · pop · pop-top-left · pop-top-right · pop-bottom-left · pop-bottom-right | "fade" | Transition preset name (or a custom style object). |