iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📌

Fixing Transparent Buttons when using Tailwind CSS with Next.js and Ant Design

に公開

Conclusion

tailwind.config.js
  corePlugins: { //Added
    preflight: false
  }

Situation

pages/index.tsx
import Image from 'next/image'
import { Button } from 'antd'


export default function Home() {
  return (
      <>
          <h1>Hello World</h1>
          <div>
              <Button size="large" type="primary">
                  Button
              </Button>
          </div>
      </>
  );
}


As shown here, the button becomes transparent.

Solution

tailwind.config.js
  plugins: [],
  corePlugins: { //Added
    preflight: false
  }
}

Add the corePlugins setting. It seems to be explained in the following video as well. It appears to disable Tailwind CSS's style reset.
https://youtu.be/oG6XPy1t1KA

Reference

https://stackoverflow.com/questions/71715157/tailwinds-ant-design-button-color-is-white-but-has-own-color-wnen-i-hover-it

Discussion