Customizing the colors of an Ant Design header

I am currently attempting to modify the background color of the entire header in antdesign. I believe the file containing the default settings can be found here: https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less

Upon inspecting this file, I have identified where the header color is defined and successfully changed it to red.

In the Global.less file:

@import "./vars.less";

@layout-header-background: red;

However, I have noticed that this change is being overridden by another class

My main query now is what would be considered the best practice for achieving a successful modification of the header color.

Answer №1

To change the background color of the <Header />, you can use JSS or apply a class to it:

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

Alternatively,

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

In your CSS file, you can define the following:

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

If you are seeing the color of the <Menu/> component instead, you can modify its color using JSS or by adding a class:

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

You can view a sample here:

https://codesandbox.io/s/header-content-footer-antd4131-forked-stiw3

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Step-by-step guide to accessing the detail view upon selecting a table row in react.js

In my project, I have a table with multiple rows. When a row is selected, I want to display detailed information about that particular item. To achieve this functionality, I am utilizing react-router-dom v6 and MUI's material table component. Here is ...

Guide on how to deactivate the Navbar component on specific dynamic routes in next.js

I have found one method to achieve this using the next router, specifically for static routes like /dashboard'. However, I am searching for a solution for dynamic URLs such as '/story/[slug]'. Layout.js const Layout=({children })=>{ i ...

How do I customize the TablePagination caption in Material-UI to display the number of rows being shown?

I am looking to replace the word "of" with a different word in my code, I attempted to do so within the node_modules but was unsuccessful. Here is the snippet of my code: <TableFooter> <TableRow> <TablePagination rowsPerPageOpti ...

Encountering an issue with Next.js React SSR using styled-jsx: unable to access the 'state' property as

I've come across a problem that I can't seem to figure out. Despite my attempts to search for a solution here, I haven't been able to help myself. I'm new to javascript and react, so please bear with me. Issue: I'm using React (1 ...

Exploring the organization of a single model in React Redux with a variety of data types - a comprehensive guide

I am working on a React Redux application that allows users to rate and view their ratings. The API methods I will be implementing are: Rating#Create (for posting a rating on a user) Rating#Index (to retrieve a JSON object of the ratings for the current ...

What is the best way to instruct npm to generate a .min.css file from scss?

Currently, I have setup a process to automatically compile CSS from SCSS using a JSON script. However, the issue is that the ".min" suffix is being removed during this compilation. Here is the output from the terminal displaying the script I am running and ...

Is redirecting the user after authentication possible? The replace function is not available for use

I am working on implementing user authentication before displaying the home page in my react app. Many tutorials suggest using a "replace" method within react-router, but I keep encountering errors that say replace is not a function. Below is my code snip ...

Automatically Scrolling Div According to its Content

Struggling to figure out how to make a parent div automatically scroll based on its child's content. I have a menu that expands when clicked and needs to scroll if the height of the child exceeds that of the parent. This is the HTML for the menu wra ...

Obtaining two divisions that simultaneously display partials in a parallel manner

It's proving difficult to align two divs containing rendered partials side by side within a form. Strangely enough, when I replace the divs with plain text, they respond perfectly to my style changes. However, as soon as I include the render code, the ...

I encountered a response error code 500 from the development server while using my emulator

As I embark on setting up the react-native environment for development, I encounter an error when executing the command react-native run-android. root@pc:~/l3/s2/DevMobMultipltm/Wakapp# ` A series of tasks are carried out including scanning folders for sy ...

What can I do to resolve the problem with td border

Check out my website over at browsethewebclean.com I've come across a peculiar issue with the borders and background color of some nested tables on my page. It seems that the border is not aligning properly and the background color goes beyond the im ...

Initializing the client-side in Next.js when using static HTML export

We are currently in the process of developing a Next.js application that utilizes react-i18next for localization. Our approach involves using next export for Static HTML Export as specified in the Next.js documentation. The challenge we have encountered is ...

Full comprehension with a width of 100%

Here is an example where .flex2 has 2 children. 1st child - width: 300px 2nd child - width: 100% .b{ height: 50px; } .flex2{ margin-top: 20px; display: flex; .box{ background-color: blue; width: 300px; } .box1{ backgroun ...

Utilizing React Typescript to dynamically render a duo of components

On a single page, I want to display two components simultaneously. There is a bottom navbar that, when clicked on, for example the profile icon, should render the profile page. However, I would like to change the color of the icon based on which component ...

Is there a way to activate an Electron API using a remote server?

Hello all, I am relatively new to Electron development and have an interesting idea that I want to implement: My goal is to send a request to an express server from a website outside of my electron app along with some data. I then want the express route t ...

Using variables in className with Next.js CSS modules

I am trying to create a loop that duplicates elements multiple times and assign dynamic classNames to each element. However, the classNames are showing up as ClassName='undefined1', ClassName='undefined2', and so on. import Style from & ...

I am unable to implement code coverage for Cypress in Debian at the moment

Having trouble obtaining code coverage results using Cypress in my Virtual Machine (Debian Bullseye), but no issues when I run the same project on my Windows machine. On Linux, the code coverage shows up as: Click here to view Index.html inside lcov-repor ...

Can TypeScript and JavaScript be integrated into a single React application?

I recently developed an app using JS react, and now I have a TSX file that I want to incorporate into my project. How should I proceed? Can I import the TSX file and interact with it within a JSX file, or do I need to convert my entire app to TSX for eve ...

Seeking a precise placement, must find a CSS-only answer

After spending two days experimenting with different CSS styles like absolute positioning, inline/inline-block display, and flex display, I have yet to find a solution for styling a timestamp's label position using pure CSS. https://i.stack.imgur.com ...

Encountering issues while trying to duplicate react-table CodeSandbox: API error when using localhost

Trying to implement this CodeSandbox project into my own project has been challenging. On navigating to the Example component, a 404 error pops up: Error: Request failed with status code 404. The API is targeting this endpoint: http://localhost:3000/api/pr ...