Having trouble changing the background color of the <AppBar>
in my project. Using the Container
component to set a maximum screen size, but encountering issues when the screen exceeds this limit. The AppBar
background color appears as expected while the rest remains white.
Is there a way to remove the white color and have it match the <AppBar>
background color seamlessly?
https://i.sstatic.net/u5l1s.png
How can I make sure that the white color matches the <AppBar>
color to ensure consistency in navigation appearance?
This is the current code snippet:
import React from 'react';
import {CssBaseline, Container} from '@material-ui/core/';
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 Button from '@material-ui/core/Button';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu';
const useStyles = makeStyles(theme => ({
root: {
flexGrow: 1,
},
menuButton: {
marginRight: theme.spacing(2),
},
title: {
flexGrow: 1,
},
}));
export default function ButtonAppBar() {
const classes = useStyles();
return (
<div className={classes.root}>
<CssBaseline />
<Container maxWidth="sm">
<AppBar position="static">
<Toolbar>
<IconButton edge="start" className={classes.menuButton} color="inherit" aria-label="menu">
<MenuIcon />
</IconButton>
<Typography variant="h6" className={classes.title}>
News
</Typography>
<Button color="inherit">Login</Button>
</Toolbar>
</AppBar>
</Container>
</div>
);
}
What could be missing here?
The navigation appearance seems off due to the surrounding white color.