timolins / react-hot-toast

Smoking Hot React Notifications šŸ”„
https://react-hot-toast.com
MIT License
9.78k stars 331 forks source link

Custom toasts, followed the website, but animation not working at all #184

Open clam61 opened 2 years ago

clam61 commented 2 years ago

If I try the sample from the webpage. My toast appears and it is styled, but there is no animation in or out.

"tailwindcss": "^3.0.7",
"autoprefixer": "^10.4.0",
"react-hot-toast": "^2.2.0",
toast.custom((t) => (
      <div
        className={`bg-white px-6 py-4 shadow-md rounded-full ${
          t.visible ? 'animate-enter' : 'animate-leave'
        }`}
      >
        Hello TailwindCSS! šŸ‘‹
      </div>
    ));

I also extended my tailwind.config.js with animate-enter and animate-leave, which I got from this repo (https://github.com/timolins/react-hot-toast/blob/main/site/tailwind.config.js) :

module.exports = {
  content: [
    './pages/**/*.{js,ts,jsx,tsx}',
    './components/**/*.{js,ts,jsx,tsx}',
  ],
  theme: {
    extend: {
      boxShadow: {
        't-sm': '0 -1px 2px 0 rgba(0, 0, 0, 0.05)',
        't-md': '0 -4px 6px -1px rgba(0, 0, 0, 0.1)',
        't-lg': '0 -10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
        't-xl': '0 -20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)',
        't-2xl': '0 -25px 50px -12px rgba(0, 0, 0, 0.25)',
        't-3xl': '0 -35px 60px -15px rgba(0, 0, 0, 0.3)',
      },

      animation: {
        enter: 'enter 200ms ease-out',
        'slide-in': 'slide-in 1.2s cubic-bezier(.41,.73,.51,1.02)',
        leave: 'leave 150ms ease-in forwards',
      },
      keyframes: {
        enter: {
          '0%': { transform: 'scale(0.9)', opacity: 0 },
          '100%': { transform: 'scale(1)', opacity: 1 },
        },
        leave: {
          '0%': { transform: 'scale(1)', opacity: 1 },
          '100%': { transform: 'scale(0.9)', opacity: 0 },
        },
        'slide-in': {
          '0%': { transform: 'translateY(-100%)' },
          '100%': { transform: 'translateY(0)' },
        },
      },

    },
  },
  plugins: [
    require('@tailwindcss/forms'),
    require('autoprefixer'),
  ],
}
miahthegreat commented 2 years ago

Same issue here. No luck with it animating aside from using the default toast and not the custom one.

timolins commented 2 years ago

This issue seems to be caused by TailwindCSS not generating the necessary styles.

However, I do see it's not ideal that the example on the website is not easily reproducible.

Is this related to to #187?