Looking for the way to create a horizontal navigation menu for the web application using material-ui components. I'd like to start with something very similar to the menu at the react documentation website:
Since it's a quite common menu look, I was searching for the example of such configuration but was unable to found it either at material-ui docs or here at SO (there is a similar solution, but it is not exactly what's needed).
How to do this?
Create a Drawer. js file in the component folder and in that file, create a DrawerComponent function. Import Drawer from Material UI, then create a function named DrawerComponent which will return a Drawer and a ListItem and this is where we will place the list of items we want in our responsive navigation bar.
Learning about the AppBar and Toolbar components in Material-UI. The navigation bar is one of the first things users see on a website. You can create a beautiful navigation bar easily in React using the component library from Material-UI.
mui-appbar container that automatically adjusts its height based on the viewport dimensions: 48px (phone landscape) 56px (phone portrait) 64px (default)
My solution for this was to place a ToolbarGroup component within AppBar's iconElementRight property.
// Defining a stateless, functional component, MyNavLinks.
// This component contains your navigation links.
const MyNavLinks = () => (
<ToolbarGroup>
<FlatButton label="Dashboard" containerElement={<Link to="dashboard"/>}/>
<FlatButton label="Settings" containerElement={<Link to="settings" />}/>
<FlatButton label="Profile" containerElement={<Link to="profile" />}/>
</ToolbarGroup>
);
// Another stateless, functional component, MyAppBar.
// Here we are setting the iconElementRight property of Material UI's AppBar
// to the component defined above.
const MyAppbar = () => (
<AppBar
title="Brand"
iconElementRight={<MyNavLinks />}
/>
);
Result:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With