React Transition Component: Streamlining Element Animations Simply

React Transition

a simple component for element transition in React

Demo

Installation

The package can be installed via npm:

npm install react-element-transition --save

Usage

React Component:

import {ReactTransition} from "./components";
import {useState} from "react";

function App() {
  const [isShow, setIsShow] = useState(true)
  return (
    <div>
      <button onClick={() => setShow(!show)}>show/hide</button>
      
      <ReactTransition value={show} onTransitionEnd={doSomtingh} name="fade" ref="fooRef">
        <div>hello</div>
      </ReactTransition>
    </div>
  )
}

export default App

Transition CSS

add in your styles file.

.fade-enter-active,
.fade-leave-active {
  transition: opacity .4s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

Props

Here are the props that can be passed to the <ReactTransition /> component:

Prop NameTypeDefault ValueDescriptionvalueBooleantrueControls the visibility of the component.onTransitionEndFunctionundefiendEvent handler for transition end.nameStringfadeSpecifies the class name for styling.refReact.RefObjectundefiendA forwarded ref for accessing the child component’s instance or DOM node.childrenReactElementnullNested content to be rendered inside the component.

Prop Details

children

  • Type: ReactElement
  • Default Value: null
  • Description: Nested content to be rendered inside the component. Note: It’s recommended to always wrap children inside a div.

Contributing

If you want to contribute to this project and make it better, your help is very welcome. Create an issue or submit a pull request.

Acknowledgments

my project’s simple transition effects draw inspiration from the powerful capabilities of Vue.js transitions.

Vue.js

The simplicity and effectiveness of Vue.js transitions have influenced the design of our basic transition features. We extend our appreciation to the Vue.js community for their powerful and versatile solutions.

Special thanks to my friend mehdi who helped and support during the development of this project.

GitHub

View Github


Related Posts

Recent Posts

ഇടുക്കിയിലെ മലയോര മേഖലകളിൽ രാത്രിയാത്ര നിരോധിച്ചു. രാത്രി ഏഴു മുതൽ രാവിലെ ആറു വരെയാണ് നിരോധനം

ഏന്തയാർ ഈസ്റ്റിൽ പ്രളയത്തിൽ തകർന്ന പാലത്തിന് പകരം പുതിയ പാലം നിർമ്മിക്കുവാൻ താത്ക്കാലിക പാലം പൊളിച്ച് നീക്കി

Explore the Investment Opportunities: A Comprehensive Guide to Different Types of Mutual Funds

Title: Understanding Mutual Funds: A Beginner's Guide to Investing

തീവ്രമഴ മുന്നറിയിപ്പിന്റെ പശ്ചാതലത്തിൽ സംസ്ഥാനം ജാഗ്രതയിൽ

250,000 അപേക്ഷകൾ വർദ്ധിച്ചതിനാൽ ട്രാൻസ്‌പോർട്ട് കമ്മീഷണർ പരിശോധന പുനരാരംഭിക്കും

ഏലക്കയിൽ കീടനാശിനി സാന്നിധ്യം; ആറര ലക്ഷത്തിലധികം ടിൻ അരവണ നശിപ്പിക്കാൻ ടെൻഡർ ക്ഷണിച്ച് ദേവസ്വം ബോർഡ്‌

ഭീമൻ പാറക്കഷണങ്ങൾ അടർന്ന് ദേശീയ പാതയിലേക്ക് വീഴുന്നത് പതിവാകുന്നു. കുട്ടിക്കാനത്തിനും മുണ്ടക്കയത്തിനുമിടയിൽ നിലനിൽക്കുന്നത് വൻ അപകട ഭീഷണി

ചക്രവാതച്ചുഴി:അതിശക്തമായ മഴ വരുന്നു

പ്ലസ് വൺ പ്രവേശനം. അക്ഷയയിൽ തിക്കി തിരക്കേണ്ട, നെറ്റിവിറ്റി/ജാതി തെളിയിക്കാൻ പത്താംതരം സർട്ടിഫിക്കറ്റ് മതി