Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
How to use sx prop in react to change the color of a navbar?

I am attempting to create a black navbar in react. Here is my code so far:

import UploadIcon from "@mui/icons-material/Upload";
import CustomButton from "./CustomButton";
import AppBar from '@mui/material/AppBar';
import Toolbar from '@mui/material/Toolbar';
import {createMuiTheme} from '@material-ui/core/styles'

const Header = () => {
    return (
        <AppBar sx = {{color:'black'}}
            position="sticky">
            <Toolbar variant="dense">
                <CustomButton
                    text='Upload' endIcon={<UploadIcon/>}/>
            </Toolbar>
        </AppBar>

    )
}
export default Header;

The techniques that I have tried so far to change the color of my appbar have been solutions proposed here: https://smartdevpreneur.com/setting-material-ui-appbar-color-and-styling/#Method_1_Styling_AppBar_With_Classes

All previous threads I've seen in stack overflow about this have also not helped me. How do I change the color of my navbar ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Styling the toolbar instead of styling the appbar worked. Here is my final code

import UploadIcon from "@mui/icons-material/Upload";
import CustomButton from "./CustomButton";
import AppBar from '@mui/material/AppBar';
import Toolbar from '@mui/material/Toolbar';
import {createMuiTheme} from '@material-ui/core/styles'


const Header = () => {
    return (
        <AppBar
            position="sticky">
            <Toolbar
                sx = {{background:'black',}}
                variant="dense">
                    <CustomButton
                        text='Upload'
                        endIcon={<UploadIcon/>}/>
            </Toolbar>
        </AppBar>
    )
}
export default Header;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!