Show the component; triggers the enter or exit states
Transitions
Chakra exports four components Fade
, ScaleFade
, Slide
, and SlideFade
to
provide simple transitions.
Import#
Most transition components are made using framer-motion
. They accept the
following props:
- Common props from framer's
motion
elements in
prop used to trigger the transitionunmountOnExit
prop used to unmount the component when it is not visible.
import { Fade, ScaleFade, Slide, SlideFade } from "@chakra-ui/react"
Usage#
Fade transition#
ScaleFade transition#
Slide transition#
Slide Fade transition#
Collapse transition#
The Collapse component is used to create regions of content that can expand/collapse with a simple animation. It helps to hide content that's not immediately relevant to the user.
Changing the startingHeight#
Props#
The transition components extends the framer-motion.
Fade Props#
in
in
boolean
unmountOnExit
unmountOnExit
If true
, the element will unmount when `in={false}` and animation is done
boolean
ScaleFade Props#
in
in
Show the component; triggers the enter or exit states
boolean
initialScale
initialScale
The initial scale of the element
number
0.95
reverse
reverse
If true
, the element will transition back to exit state
boolean
unmountOnExit
unmountOnExit
If true
, the element will unmount when `in={false}` and animation is done
boolean
Slide Props#
direction
direction
The direction to slide from
"bottom" | "left" | "right" | "top"
"right"
in
in
Show the component; triggers the enter or exit states
boolean
unmountOnExit
unmountOnExit
If true
, the element will unmount when `in={false}` and animation is done
boolean
SlideFade Props#
in
in
Show the component; triggers the enter or exit states
boolean
offsetX
offsetX
The offset on the horizontal or x
axis
string | number
0
offsetY
offsetY
The offset on the vertical or y
axis
string | number
8
reverse
reverse
If true
, the element will be transitioned back to the offset when it leaves.
Otherwise, it'll only fade out
boolean
true
unmountOnExit
unmountOnExit
If true
, the element will unmount when `in={false}` and animation is done
boolean
Collapse Props#
animateOpacity
animateOpacity
If true
, the opacity of the content will be animated
boolean
true
endingHeight
endingHeight
The height you want the content in its expanded state.
string | number
"auto"
in
in
Show the component; triggers the enter or exit states
boolean
startingHeight
startingHeight
The height you want the content in its collapsed state.
string | number
0
unmountOnExit
unmountOnExit
If true
, the element will unmount when `in={false}` and animation is done
boolean