Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is default navbar on Material UI exist like Bootstrap does?

I found it hard to create navbar with menus on Material UI. I've read it's AppBar documentation. But, it seems they doesn't provide that feature.

1) Material UI AppBar

enter image description here

2) React Bootstrap Navbar

enter image description here

How to create navbar menu on Material UI like React Bootstrap does ?

like image 928
Rido Avatar asked Sep 05 '17 10:09

Rido


1 Answers

Unfortunately, Material-UI doesn't provide a navbar component like Bootstrap does. (It does have an appbar though, but I don't think that's what you're looking for). Also, it doesn't give you the automatic responsiveness out-of-the-box like bootstrap. It just gives you the tools so you have to take care of it yourself.

enter image description here

A navbar, however can be composed using some basic MUI components with flex:

import React from "react";
import "./styles.css";
import { Box, Typography, Button, IconButton } from "@material-ui/core";
import MenuIcon from "@material-ui/icons/Menu";

export default function App() {
  return (
    <Box display="flex" bgcolor="grey.200" p={2} alignItems="center">
      <Typography>React-bootstrap</Typography>
      <Box>
        <Button color="primary">Link</Button>
        <Button color="primary">Link</Button>
      </Box>
      <Box flexGrow={1} textAlign="right">
        <IconButton>
          <MenuIcon />
        </IconButton>
      </Box>
    </Box>
  );
}

Here's the live demo:

like image 103
Mohsen Taleb Avatar answered Nov 11 '22 01:11

Mohsen Taleb