use-collapsible-hook
v1.0.3
Published
A React.js hook for creating collapsible content.
Downloads
5
Maintainers
Readme
use-collapsible-hook
A React.js hook for creating collapsible content.
Installation
npm install use-collapsible-hook
Usage
import React from 'react';
import useCollapsible from 'use-collapsible-hook';
const App = () => {
const {
ref,
isCollapsed,
height,
onToggle,
} = useCollapsible(true);
return (
<div>
<button onClick={onToggle}>Toggle</button>
<div ref={ref} style={{
height: isCollapsed ? 0 : height
}}>
<p>Some collapsible content</p>
<p>More collapsible content</p>
<p>Even more collapsible content</p>
</div>
</div>
);
};