Transitions
All of the react-md
components that have a transition use the
useCSSTransition hook to generate simple CSS
transitions. If a component uses a CSS transition, it will expose a timeout
and classNames
prop to customize the transition behavior.
Transition Timeouts
react-md
default to animating between 0.15s
to 0.2s
to ensure that
animations only help show the user something is happening instead of blocking
behavior. The exception is the CrossFade transition
which takes 0.3s
by default.
These default timeouts can be configured through the core.$linear-duration, core.$enter-duration, core.$leave-duration, and core.$cross-fade-transition-duration but would also need to be configured on the component level as well.
Transition Timing Functions
There are a few transition-timing-function
s available by default and can be configured.
- core.$sharp-timing-function - appear quickly
- core.$linear-timing-function - enter and exit at the same speed
- core.$acceleration-timing-function - start slow, then speed up
- core.$deceleration-timing-function - start fast, then slow down
Disabling All Transitions
If all react-md
transitions should be disabled, set the
TRANSITION_CONFIG.disabled
to true and include near the root of your app:
import { TRANSITION_CONFIG } from "@react-md/core/transition/config";
TRANSITION_CONFIG.disabled = true;
See Global Configuration for testing notes.
Default Component Transitions
Collapse
The Collapse,
ExpansionPanel,
Navigation, and Tree components
and useCollapseTransition hook cannot be
configured through Sass and instead only through the timeout
prop. It
defaults to
DEFAULT_COLLAPSE_TIMEOUT.
CrossFade
The CrossFade component and useCrossFadeTransition hook use the following defaults and configuration:
- DEFAULT_CROSS_FADE_TIMEOUT
- DEFAULT_CROSS_FADE_CLASSNAMES
- core.$cross-fade-translate-distance
- core.$cross-fade-transition-duration
Dialog
The Dialog component will animate with opacity and sliding upwards a short distance. It uses the following defaults and configuration:
- DEFAULT_DIALOG_TIMEOUT
- DEFAULT_DIALOG_CLASSNAMES
- core.$dialog-transition-distance
- core.$dialog-enter-duration
- core.$dialog-enter-timing-function
- core.$dialog-leave-duration
- core.$dialog-leave-timing-function
ScaleTransition
The ScaleTransition, Menu, Autocomplete, Select, and Snackbar components and useScaleTransition hook use . It uses the following defaults and configuration:
- DEFAULT_SCALE_TIMEOUT
- DEFAULT_SCALE_CLASSNAMES
- DEFAULT_SCALE_Y_CLASSNAMES
- core.$scale-transition-enter-duration
- core.$scale-transition-leave-duration
- core.$scale-y-transition-enter-duration
- core.$scale-y-transition-leave-duration
Sheet
The Sheet component will slide from outside the viewport and stick to the edge whenever it becomes visible. It uses the following defaults and configuration:
- DEFAULT_SHEET_TIMEOUT
- DEFAULT_SHEET_CLASSNAMES
- core.$sheet-enter-duration
- core.$sheet-enter-timing-function
- core.$sheet-leave-duration
- core.$sheet-leave-timing-function
SkeletonPlaceholder
The SkeletonPlaceholder component and useSkeletonPlaceholder hook animate by changing the opacity of the element. It uses the following defaults and configuration:
- core.$skeleton-placeholder-animation
- core.$skeleton-placeholder-animation-duration
- core.$skeleton-placeholder-animation-timing-function
Slide
The Slide component and useSlideTransition hook animate by sliding from some point to another point using CSS transforms. It uses the following defaults and configuration:
- DEFAULT_SLIDE_TRANSITION_TIMEOUT
- DEFAULT_SLIDE_TRANSITION_CLASSNAMES
- core.$slide-duration
- core.$slide-timing-function
Overlay
The Overlay component uses a simple opacity transition
from 0
to 1
whenever it becomes visible and uses the following defaults and
configuration: