Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Fades a div in/out when toggled
# react_transition_group/demo/App1.jsx
import React, { useState } from 'react'
import { CSSTransition } from 'react-transition-group'
import './styles.css'
function App() {
const [show, setShow] = useState(false)
return (
<div>
<button onClick={() => setShow(!show)}>Toggle</button>
<CSSTransition in={show} timeout={300} classNames="fade" unmountOnExit>
<div className="box">Hello!</div>
</CSSTransition>
</div>
)
}
export default AppReact Transition Group (RTG) is a lightweight animation utility for React that enables transitions when components enter, exit, or change state. It provides simple APIs such as CSSTransition, Transition, SwitchTransition, and TransitionGroup to orchestrate animations without dictating animation styles or mechanics.
Origin & Creator
React Transition Group was originally developed by the React community as part of React addons, later split into its own standalone package maintained by the React team and open-source contributors.
Industrial Note
RTG is widely used in UI-heavy React apps, dashboards, modals, dropdowns, list animations, route transitions, marketing pages, and any place requiring controlled mount/unmount animations.