Skip to content

React component for a nested navigation menu. Easily create an Amazon-like menu with an unlimited amount of nesting.

Notifications You must be signed in to change notification settings

UseAllFive/react-nested-nav

Repository files navigation

react-nested-nav

React nested navigation menu

NPM JavaScript Style Guide

Install

npm install --save react-nested-nav

Usage

Format your data

See example data here

const MenuShape = {
  title: PropTypes.string,
  id: PropTypes.string
}
const ItemsShape = {
  text: PropTypes.string.isRequired,
  link: PropTypes.string
}
ItemsShape.menu = PropTypes.shape(MenuShape)
MenuShape.items = PropTypes.arrayOf(PropTypes.shape(ItemsShape))
NestedNav.propTypes = {
  menus: PropTypes.shape(MenuShape),
  onLinkClick: PropTypes.func
}
import React from 'react'

import { NestedNav } from 'react-nested-nav'
import { data } from './data' // see data formatting
import 'react-nested-nav/dist/index.css' // custom css

const App = () => {
  return (
    <NestedNav
      menus={data}
      onLinkClick={(link) => {
        console.log(`go to: ${link}`)
      }}
    />
  )
}

export default App

License

MIT © UseAllFive

About

React component for a nested navigation menu. Easily create an Amazon-like menu with an unlimited amount of nesting.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published