timolins / react-hot-toast

Smoking Hot React Notifications 🔥
https://react-hot-toast.com
MIT License
9.85k stars 331 forks source link

Trouble with className #350

Closed Android789515 closed 8 months ago

Android789515 commented 8 months ago

I'm trying to set up class name:

<Toaster
   toastOptions={{
      // Not working
      className: styles.toaster,

      // Not working
      className: 'toaster',

      // Working
      style: {
         background: 'red',
      },
   }}
/>

My CSS:

.toaster {
   background: red;
}
Android789515 commented 8 months ago

The issue was specificity. Overriding default styles can be a pain in CSS modules as you have to override the specificity of the default class.

The current fix, increase specificity:

.toaster.toaster {
   background: red;
}