Description
In my NextJS project, I am using the Ant Design V5 framework with multiple pages. However, I am facing an issue where the styles are only working correctly on one page and not being applied properly on other pages. Despite referring to the official documentation and examples from Ant's GitHub repository, I couldn't resolve this styling inconsistency.
Questions
These are the questions puzzling me:
- What makes that particular page behave differently with the styles?
- Why are the styles failing to work as expected on other pages?
Links
- Link to my repository (branch:
isolated-ant-bug
) - Working page - http://localhost:3000/en/m/main
- Broken page - http://localhost:3000/en/m/home
- Page with broken styles - http://localhost:3000/en
- Official Ant Design document - https://ant.design/docs/react/use-with-next
- Ant Design examples on GitHub - https://github.com/ant-design/ant-design-examples/tree/main/examples
Isolated Codes:
pages/_app.tsx
import { FC } from 'react'
import { AppProps } from 'next/app'
import { ConfigProvider } from 'antd'
import '../styles/globals.css'
import 'typeface-rubik/index.css'
const MyApp: FC<AppProps> = ({ Component, pageProps }) => (
<ConfigProvider
theme={{
token: {
fontFamily: '"Rubik", sans-serif',
}
}}
>
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
<Component {...pageProps} />
</ConfigProvider>
)
...
Dependencies
{
// JSON dependency list
}
Next.js Config
// JavaScript configuration for Next.js
Screenshots
Screenshot of /home page: (link)