The issue lies in the fact that the customization of the Ant Design theme is not being properly implemented

I'm in the process of customizing the antd theme in conjunction with next.js.

After researching online, I came across a helpful example and implemented the setup like so:

// package.json
    "dependencies": {
    "@ant-design/icons": "^4.8.0",
    "antd": "^4.24.3",
    "next": "^12.3.1",
    "next-plugin-antd-less": "^1.8.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "styled-components": "^5.3.6",
    "styled-reset": "^4.4.2"
  },
  "devDependencies": {
    "babel-plugin-import": "^1.13.5"
  }
// .babelrc
{
  "presets": [
    "next/babel"
  ],
  "plugins": [
    [
      "import",
      {
        "libraryName": "antd",
        "style": true
      }
    ]
  ]
}
// next.config.js
const withAntdLess = require('next-plugin-antd-less');

module.exports = withAntdLess({  
  modifyVars: { '@primary-color': '#04f' },  
  lessVarsFilePath: './styles/variables.less',  
  lessVarsFilePathAppendToEndOfContent: false,  
  cssLoaderOptions: {},

  webpack(config) {
    return config;
  },
});
// styles/variables.less
@import '~antd/lib/style/themes/default.less';
@import '~antd/dist/antd.less';

@primary-color: #52c41a;
// pages/app.js
import React from 'react';
import { ThemeProvider } from 'styled-components';

import "../styles/variables.less";
import GlobalStyles from '../styles/GlobalStyles';
import Theme from '../styles/Theme';

const Home = ({ Component, pageProps }) => {
  return (
    <>     
      <GlobalStyles />
      <ThemeProvider theme={Theme}>
        <Component {...pageProps} />         
      </ThemeProvider>
    </>
  );
};

export default Home;
// log of executing npm run dev command
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
warn  - Invalid next.config.js options detected: 
  - The root value has an unexpected property, modifyVars, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, future, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, [...]

Despite implementing the setup, upon running the code, the changes didn't reflect as expected.

Revisiting the reference material, I attempted the settings again with no success.

Could there be an issue with my configurations?

Your insights and comments in response would be greatly appreciated.

Answer №1

Personalize your theme using ConfigProvider

import { Button, ConfigProvider } from 'antd';
import React from 'react';

const App: React.FC = () => (
  <ConfigProvider
    theme={{
      token: {
        colorPrimary: '#00b96b',
      },
    }}
  >
    <Button />
  </ConfigProvider>
);

export default App;

View the outcome. https://i.sstatic.net/PRxfL.png

For further information, refer to the official documentation here >> https://ant.design/docs/react/customize-theme

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

Is the order of SCSS (SASS) selectors important when dealing with nested classes?

Exploring SCSS Styles for List Items In this code snippet, I am investigating the order of selection for classes and pseudo-selectors in SCSS. Specifically, I am questioning whether &:before.active is equivalent to &.active:before. Here is an exa ...

Guidelines for setting up routing in a React application using Express

I have a backend set up in expressjs with multiple routes. After following a tutorial to create a RESTful api on express, I want to transition to using full react on the frontend. I plan to use fetch from react to retrieve data from the backend api. Howe ...

Facing a challenge with client-side errors upon deploying Next.js to Vercel, unfortunately, the logs aren't offering any helpful clues

After successfully deploying my NextJs application to Vercel, I encountered an issue. While the application runs perfectly when tested locally, I faced an error message upon opening it in the browser on Vercel. The browser console provided a link to the Re ...

Manipulating the location where a dropdown menu intersects with a button

Is there a way to adjust the drop-down menu positioning so that it aligns with the button on the top right side of the menu pop-up, rather than the top left as it currently does? Below is the code I have borrowed from an example on W3Schools. .dropbtn ...

What is the reason behind receiving a 401 unauthorized error during the login process?

Currently, I am utilizing the NextAuth.js credentials provider for managing the login process. While attempting to log in, I have implemented error handling using a try-catch block to set the appropriate error state; however, I haven't incorporated di ...

Customizing MaterialUI styles in React: A step-by-step guide

When utilizing Material UI with React, I am facing difficulty styling the Outline Select component according to my preferences. How can I override the default styles effectively? Even after using withStyles, I am unable to achieve the desired appearance a ...

Tips for implementing conditional styling (using else if) in a react component

Currently, while iterating through a list of header names, I am attempting to change the CSS style of a react component based on three different conditions. I have managed to make it work for one condition, but I am facing challenges when trying to impleme ...

When you add the /deep/ selector in an Angular 4 component's CSS, it applies the same style to other components. Looking for a fix?

Note: I am using css with Angular 4, not scss. To clarify further, In my number.component.css file, I have: /deep/ .mat-drawer-content{ height:100vh; } Other component.css files do not have the .mat-drawer-content class, but it is common to all views ...

The alignment of the images is off, with varying heights that do not match

My current issue involves images appearing in varying heights and the text underneath not aligning properly. Here is the markup: I have six row containers to showcase 6 different images. <div class="row"> <div class="posts"> <im ...

Expanding Perspective in React Native

Having trouble with implementing a camera feature that isn't scaling correctly. The issue seems to be related to the styling of the container View, as when the camera is rendered independently it works fine. The goal is for the camera to activate when ...

designing a responsive form in the mobile environment

I have implemented a search form on my website with a button inside the text box. It works fine on desktop, but when I switch to mobile view, the positioning is off. I am currently using absolute positioning for the button to give it a fixed position. Is t ...

Despite having a hover animation, the CSS animation remains stuck

I'm looking to create a hover animation where one picture disappears upon hovering and is replaced by another picture, but I'm having trouble getting the back picture to disappear My attempt involved changing opacity from 1 to 0 with a transitio ...

React: Modal triggering a GET request

Issue I am encountering an issue with my GET request. Every time I open or close my form dialog, or input something in it, the GET request made using fetch and the hook useEffect are triggered. Snippet import { handleErrorMessage } from "../App" ...

Using DefinePlugin in conjunction with deploying an app to Heroku may cause issues and prevent the deployment process from

I have recently been customizing my webpack bundle creation process by using UglifyJsPlugin and DefinePlugin in my webpack config instead of the traditional webpack -p command. While this approach offers more control, I encountered an issue with deploying ...

"415 (Unsupported Media Type) encountered when making a POST request in a REST API

I've encountered an issue with a React component where a checkbox triggers a POST request to a REST API with a single parameter. Despite setting a breakpoint in the WebAPI code, it's not being hit and I'm receiving a 415 Unsupported Media Ty ...

Can one attach an HTML element to the bottom of another?

I have a question regarding formatting textual documents in HTML. I'm trying to find a way to display multiple pages within a single HTML document, specifically focusing on keeping the footer at the bottom of each page. My goal is to keep it simple, p ...

Do you know of a solution to fix the Stylelint error regarding semicolons when using CSS variables?

React.js Css in JS(Emotion) The components above are part of this setup. Here is the configuration for Stylelint: module.exports = { extends: [ "stylelint-config-standard", "./node_modules/prettier-stylelint/config.js", ], ...

Troubleshooting the ineffectiveness of using the MUI onSubmit method with a

I have been using MUI for components and encountered an issue with my form not calling the onSubmit method when wrapped in the Box component. Below is a minimal example illustrating this problem. The onClick event, on the other hand, works perfectly fine ...

Can you tell me the alternatives for getServerSideProps and getStaticProps in Next.js version 14?

I'm trying to wrap my head around the rendering behavior of SSR/SSG/ISR in Next.js version 14 with the updated app router. Previously, Next.js provided predefined functions like getServerSideProps for server-side fetching and processing (SSR), or getS ...

Having trouble with the auto width CSS for the center section of my webpage

I am facing an issue with assigning widths to my divisions using the CSS calc property. Despite setting the width for the first and last divisions, I am unable to allocate any width to the middle division. HTML: <div style="width:400px;"> <div ...