Animated, lightweight expandable components for React
React Expandify π
Animated, lightweight expandable components for React. No extras, just effortless expand and collapse.
πΈ Demo
π Features
- π Plug and Play: Get started instantly, no complicated setup!
- π Elemental Freedom: Use any HTML element as your expandable container.
- π¨ Your Style, Your Rules: Easy-to-add custom classes.
- β± Tick Tock Goes The Clock: Control the expand and collapse speed to the millisecond!
π¦ Installation
Add React Expandify
to your project with npm:
npm install react-expandify
Or use yarn:
yarn add react-expandify
π‘ Usage
Basic example:
import { Expandable } from 'react-expandify';
import 'react-expandify/dist/style.css';
const MyApp = () => (
<Expandable expanded>
<p>Your awesome content here!</p>
</Expandable>
);
π Documentation
Property | Type | Default | Description |
---|---|---|---|
expanded |
boolean |
false |
Determines whether the content is expanded or not. |
children |
ReactNode |
β | Children to be rendered inside the component. |
elementType |
JSX.IntrinsicElements |
'div' |
The HTML element type for the Expandable component. |
expandDuration |
number |
300 |
Duration for the expand animation in milliseconds. |
collapseDuration |
number |
300 |
Duration for the collapse animation in milliseconds. |
easing |
string |
ease-in-out |
Easing function for the expand and collapse animations. |
className |
string |
β | Additional className for the Expandable component. |
onCollapse |
() => void |
β | Callback when the content has collapsed. |
onExpand |
() => void |
β | Callback when the content has expanded. |
β¨ What You Can Create
Tree view
|
Accordion component
|
Toggles
|
More examples coming soon⦠|
π Contributing
Got ideas or bug reports? Open an issue or send a pull request!
π License
Licensed under the MIT License. See LICENSE for more details.
Crafted with π by Armen Nersisyan