An easy-to-use component that allows you to add responsive navigation with minimum fuss.
Install
npm i material-ui-responsive-nav @material-ui/core
NOTE: This component requires Material-UI to work.
Usage
importReactfrom"react"import{MaterialUINav}from"material-ui-responsive-nav"// you will need to import the icons from an external source to use with external linksimport{Facebook,Twitter}from"mdi-material-ui"constLayout=({children})=>{constlinks={internal: [{label: "Home",link: "/",},{label: "About",link: "/about",},{label: "Contact",link: "/contact",},],external: [{label: "Facebook",icon: Facebook,link: "https://www.facebook.com",},{label: "Twitter",icon: Twitter,link: "https://www.twitter.com",},],}return(<><MaterialUINavglobal={{siteTitle: "My cool site",mobileBreakpoint: "xs",}}navbarConfig={{elevate: false,}}mobileMenuConfig={{slideTransition: true,}}links={links}/>{children}</>)}
API
links (required)
Property
Description
Type
Options
Default
internal
An array of internal links to include in the navigation
array
[ { label: string, link: string, navbarLinkProps: object (pass props to the Button component), mobileMenuProps: object (pass props to the ListItem component), mobileMenuTextProps: object (pass props to the ListItemText component) } ]
N/A
external
An array of external links to include in the navigation
array
[ { label: string, link: string, icon: node, navbarLinkProps: object (pass props to the IconButton component), mobileMenuProps: object (pass props to the IconButton component) } ]
N/A
global
Property
Description
Type
Options
Default
siteTitle
The title to show on the navbar and the mobile menu
string
N/A
"My site"
mobileBreakpoint
The point at which to display the mobile layout
string
"xs", "sm", "md", "lg", "xl"
"sm"
navbarConfig
Property
Description
Type
Options
Default
color
Background color of the navbar
string
"primary", "secondary", "transparent"
"primary"
fixed
Fix the navbar to the top of the screen
boolean
N/A
true
appBarProps
Pass props to the AppBar component
object
N/A
null
transparentAtTop
Make the background of the navbar transparent if at the top of the page.
boolean
N/A
false
elevate
Show a box shadow
boolean
N/A
true
shrinkOnScrollDown
Shrink the height of the navbar if not at the top of the page
boolean
N/A
true
shrinkTransitionDuration
Adjust the duration in seconds of the shrink (and grow) animation. shrinkOnScrollDown must be true for this to work.
The Tidelift Subscription provides access to a continuously curated stream of human-researched and maintainer-verified data on open source packages and their licenses, releases, vulnerabilities, and development practices.