I just started learning Tailwind and I watched a tutorial. At first, the command npx tailwindcss init, which creates a file tailwind.config.js, didn't work for me. Error: Invalid command: init. This wasn't a problem, though, because I was able to use Tailwind classes normally. But when I wanted to create a keyframe, I saw that it should be created in tailwind.config.js.
I created the file manually and added the keyframe, but the keyframe didn’t work in the HTML.
// tailwind.config.js
module.exports = {
purge: {
content: ['./build/*.html', './build/js/*.js'],
safelist: ['animate-open-menu'], // Ensure your custom animation isn't purged
},
theme: {
extend: {
animation: {
// Custom animation using the defined keyframes
'open-menu': 'open-menu .5s ease-in-out forwards',
},
keyframes: {
// Custom keyframes definition
'open-menu': {
'0%': { transform: 'scaleY(0)' },
'80%': { transform: 'scaleY(1.2)' },
'100%': { transform: 'scaleY(1)' },
},
},
},
},
variants: {},
plugins: [],
};
tailwindlabs/tailwindcssdiscussion #19020 - Which TailwindCSS v4 namespace matches a given TailwindCSS v3's theme keys?