2

I am trying to change background color of entire header in antdesign. I am not sure but file with defaults should be this https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less

I found out that color of header is used here so i changed it to red

antd defaults

Global.less

@import "./vars.less";

@layout-header-background: red;

But its override with another class enter image description here

Now my question is what is best practice to achieve change of header color. I mean this thing here

1 Answer 1

4

The background color of the <Header /> can be simply change using JSS or put a class on it:

<Header style={{backgroundColor: "red"}}>...</Header>

or

<Header className="red-header">...</Header>

and in css

.red-header{
    background-color: red;
}

maybe what are you seeing is the color of the <Menu/> component. You can also modify the color of it using JSS or put a class on it:

<Menu style={{backgroundColor: "red"}} mode="horizontal">...</Menu>

see sample here

Edit

1
  • 2
    Thanks for your answer. There is only one downside with first code you shared and the problem is i cant use less variables there. Anyway i thought the right way is to edit antd variables instead of creating new classes. Again thank You .
    – user9817924
    Commented Mar 11, 2021 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.