1. Home
  2. /
  3. React-transition-group
  4. /
  5. Fade with Delay

Fade with Delay - React-transition-group Typing CST Test

Loading…

Fade with Delay — React-transition-group Code

Fades in a box with a delay

# react_transition_group/demo/App9.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 Delayed</button>
		<CSSTransition in={show} timeout={500} classNames="fade" unmountOnExit>
		<div className="box">Delayed Fade</div>
		</CSSTransition>
		</div>
	)
}

export default App

React-transition-group Language Guide

React 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.

Primary Use Cases

  • ▸Page transitions
  • ▸List item animations
  • ▸Modal, drawer, and dropdown transitions
  • ▸Button and small UI state animations
  • ▸Mount/unmount controlled effects

Notable Features

  • ▸Declarative enter/exit transitions
  • ▸Integration with CSS animations or JS-based animations
  • ▸TransitionGroup for list animation
  • ▸SwitchTransition for swapping components
  • ▸Hook-like lifecycle callbacks for animations

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.

More React-transition-group Typing Exercises

Fade ToggleSlide DownFade + ScaleHorizontal SlideFade List ItemsZoom On MountFade + Slide UpFade + Slide DownFade List Removal

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher