Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react navbar material ui

import React from "react";
import {
  AppBar,
  Toolbar,
  CssBaseline,
  Typography,
  makeStyles,
  useTheme,
  useMediaQuery,
} from "@material-ui/core";
import { Link } from "react-router-dom";
import DrawerComponent from "./Drawer";

const useStyles = makeStyles((theme) => ({
  navlinks: {
    marginLeft: theme.spacing(5),
    display: "flex",
  },
  logo: {
    flexGrow: "1",
    cursor: "pointer",
  },
  link: {
    textDecoration: "none",
    color: "white",
    fontSize: "20px",
    marginLeft: theme.spacing(20),
    "&:hover": {
      color: "yellow",
      borderBottom: "1px solid white",
    },
  },
}));

function Navbar() {
  const classes = useStyles();
  const theme = useTheme();
  const isMobile = useMediaQuery(theme.breakpoints.down("md"));

  return (
    <AppBar position="static">
      <CssBaseline />
      <Toolbar>
        <Typography variant="h4" className={classes.logo}>
          Navbar
          
        </Typography>
        {isMobile ? (
          <DrawerComponent />
        ) : (
          <div className={classes.navlinks}>
            <Link to="/" className={classes.link}>
              Home
            </Link>
            <Link to="/about" className={classes.link}>
              About
            </Link>
            <Link to="/contact" className={classes.link}>
              Contact
            </Link>
            <Link to="/faq" className={classes.link}>
              FAQ
            </Link>
          </div>
        )}
      </Toolbar>
    </AppBar>
  );
}
export default Navbar;
Comment

material ui navbar

import React, { useState } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import IconButton from '@material-ui/core/IconButton';
import Button from '@material-ui/core/Button';
import MenuIcon from '@material-ui/icons/Menu';
import ModalDialog from './ModalDialog';

const useStyles = makeStyles(theme => ({
  menuButton: {
    marginRight: theme.spacing(2),
  },
  title: {
    flexGrow: 1,
  },
}));

const Navbar = () => {
  const classes = useStyles();
  const [open, setOpen] = useState(false);

  const handleOpen = () => {
    setOpen(true);
  };

  const handleClose = () => {
    setOpen(false);
  };

  return (
    <AppBar position="static">
      <Toolbar>
        <IconButton
          edge="start"
          color="inherit"
          aria-label="menu"
          className={classes.menuButton}
        >
          <MenuIcon />
        </IconButton>
        <Typography variant="h6" className={classes.title}>
          Title
        </Typography>
        <Button color="inherit" onClick={handleOpen}>
          Signup
        </Button>
      </Toolbar>
      <ModalDialog open={open} handleClose={handleClose} />
    </AppBar>
  );
};

export default Navbar;
Comment

PREVIOUS NEXT
Code Example
Javascript :: execute shell command in javascript 
Javascript :: express post 
Javascript :: js access array in array 
Javascript :: react: fow to use find(to get the id of a element 
Javascript :: react js big calendar 
Javascript :: form an array from i to j javascript 
Javascript :: how to go back to previous route in next.js 
Javascript :: print() in javascript 
Javascript :: redux devtools config 
Javascript :: javascript get object in object 
Javascript :: cet time zone right now 
Javascript :: from array create two arrayjavascript 
Javascript :: js number round to each 15 
Javascript :: how to check characters inside a string javascript 
Javascript :: scroll up link 
Javascript :: export json to excel in javascript 
Javascript :: sort array in javascript 
Javascript :: open modal on clicking select option in react 
Javascript :: form contact 7 ajax send 
Javascript :: js array concat 
Javascript :: print in javascript 
Javascript :: js add timestamp clg 
Javascript :: javascript zoom image onclick 
Javascript :: isupper 
Javascript :: node fs 
Javascript :: js download 
Javascript :: js get children last 
Javascript :: test each jest 
Javascript :: how to use react typed js 
Javascript :: how to check is the key of a localstorage is emopty 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =