AnimateSwitch#

This component extends Switch component of react-router-dom and provides additionnal props for animating contained routes.

Use animationType prop to do basic animations:

  • fade (default)
  • scale
  • slide up
  • slide down
  • slide left
  • slide right

If your not satisfied with these animations, you can do your own animation with some framer-motion imported props (inherited from MountTransition). See below.

Example#

import { AnimateSwitch, AnimateRoute } from 'la-danze-ui';
function App() {
return (
...
<AnimateSwitch animationType="slideLeft">
// AnimateSwitch can only be used with AnimateRoute
<AnimateRoute path="/example">example</AnimateRoute>
...
</AnimatedSwitch>
);
}

Props#

Extends Switch props

Additional props:

NameTypeDefaultRequiredDescription
animationType'fade'
|'scale'
|'slideUp'
|'slideDown'
|'slideLeft'
|'slideRight'
'fade'No Animation type of all contained routes. Overrides variants prop. Overriden by AnimateRoute animationType prop.
animationKeyAnimationKeyNoOverride key prop. Use it only if you have nested routes. It will prevent parent route to re render.
initialTarget
|VariantLabels
|boolean
'initial'NoSee framer-motion doc.
animateAnimationControls
|TargetAndTransition
|VariantLabels
|boolean
'in'NoSee framer-motion doc.
exitTargetAndTransition | VariantLabels'out'NoSee framer-motion doc.
transitionTransition{ duration: 0.225 }NoSee framer-motion doc.
variantsVariantsNoSee framer-motion doc.
styleMotionStyleNoSee framer-motion doc.