P粉6765887382023-08-11 14:28:01
You can easily do this by adding the following code to your code:
className={md:${window.scrollY > 0 ? "bg-slate-50" : "bg-transparent"}}
This is what Tailwind does. Otherwise you can write custom CSS yourself.
Please note, please make sure to include the required variants in your tailwind.config.js
if not already enabled:
module.exports = { variants: { backgroundColor: ['responsive', 'hover', 'focus'], // ... other configurations }, }
P粉4929595992023-08-11 11:56:12
${window.scrollY > 0 ? "max-md:bg-slate-50" : ""}
You can also learn more from the Tailwind documentation: https://tailwindcss.com/docs/responsive-design#targeting-a-single-breakpoint