Skip to Content
Puzzle
UI ComponentsUtilities

Transition

Animate mounting and unmounting with reusable CSS transition templates.

Import

import { Transition } from "@puzzle-ui/ui";

Visibility and templates

Without as, Transition animates its single child directly. Use as to animate a wrapper around multiple children. Toggle the preview to see entry and exit.

390 × 350

API

PropTypeDefaultDescription
visiblebooleanRequiredEnter or exit state.
childrenReactNodeRequiredA single element unless as creates a wrapper.
asElementType-Optional animated wrapper.
template"fade" | "slide-in-up" | "slide-in-down" | "slide-in-left" | "slide-in-right" | "accordion"Fade behaviorBuilt-in CSS classes.
enterFrom, enterTo, exitTostringTemplate classesCustom phase classes.
durationnumber300Transition duration in milliseconds.
unmountOnExitbooleantrueRemove content after exiting.
forceMountbooleanfalseKeep content mounted regardless of visibility.
onEnter, onEntered, onExit, onExited() => void-Lifecycle callbacks.
classNamestring""Animated element classes.

Remaining native props target the wrapper or cloned child. Built-in styles respect reduced-motion preferences. Custom transitions should do the same. Hidden content should not contain reachable interactive controls; consider unmounting rather than keeping such content mounted.

;