Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
react-animated-menu
Advanced tools
A React component that handles all logic for managing visual state for menus and lists.
Simple primitives to build dynamic menu and list components. ☰
You want to build a sidebar for your app's dashboard — maybe create a table of contents for your documentation page. When you click on a link in the sidebar you want to expand the contents.
You also want to use a simple plug and play API that controls the opening/closing of menus items, lets you control the ease and duration of the menu animation, and allows you flexibility to build your UI however you'd like.
react-animated-menu
manages all menu state and user interactions for you so you can simply focus on building your UI.
It uses a single compound component paired with a render prop to provide maximum flexibility, exposing only props that are valuable for you.
NOTE: This solution transforms the menu's
height
property. Typically we should be animating CSS transforms; however, in this particular case, using plain Javascript to transition height is a lot simpler.
Install this module as a dependency using npm
or yarn
npm install --save react-animated-menu
or
yarn add -D react-animated-menu
There are 2 components that this module provides - simply use them like this:
import DynamicMenu, { MenuItem } from 'react-animated-menu'
export default function Menu() {
return (
<aside>
{/* Wrap the menu in a Higher Ordered Component */}
<DynamicMenu
initialOpenIndex={0}
easeDuration={150}
numberOfMenusThatCanBeOpenedAtOnce={1}
>
{/* Each menu toggler and the menu list content must be wrapped by a MenuItem
render prop - and spreading the prop getters to their respective sections. */}
<MenuItem>
{({ isOpen, getToggleProps, getMenuProps, getLinkProps }) => (
<>
<button {...getToggleProps()} isOpen={isOpen}>
Dashboard
</button>
<ul {...getMenuProps()}>
{dashboardPaths.map(p => (
<li key={p.route}>
<Link to={`/${p.route}/`} {...getLinkProps()}>
{p.name}
</Link>
</li>
))}
</ul>
</>
)}
</MenuItem>
{/* Same as above MenuItem! */}
<MenuItem>
{({ isOpen, getToggleProps, getMenuProps, getLinkProps }) => (
<>
<button {...getToggleProps()} isOpen={isOpen}>
Settings
</button>
<ul {...getMenuProps()}>
{settingPaths.map(p => (
<li key={p.route}>
<Link to={`/${p.route}/`} {...getLinkProps()}>
{p.name}
</Link>
</li>
))}
</ul>
</>
)}
</MenuItem>
</DynamicMenu>
</aside>
)
}
The nested child elements.
number | number[] - defaults to -1 (all menu items closed)
The initial MenuItem that should be open.
number - defaults to 1
The number of menus that can be opened at once. 😀
(t: number) => number
An easing function - see https://gist.github.com/gre/1650294 for a list of options.
number - defaults to 150 (ms)
Duration of the menu transition.
MIT
FAQs
A React component that handles all logic for managing visual state for menus and lists.
The npm package react-animated-menu receives a total of 1 weekly downloads. As such, react-animated-menu popularity was classified as not popular.
We found that react-animated-menu demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.