Open danialhawari opened 1 year ago
It works now with TailwindCSS.
import Image from "next/image"
export default async function IndexPage() {
return (
<>
<div>
<Image
src="icon-light.svg"
width={64}
height={64}
alt="Icon"
className="block dark:hidden"
/>
<Image
src="icon-dark.svg"
width={64}
height={64}
alt="Icon"
className="hidden dark:block"
/>
</div>
</>
)
}
Hey everyone,
I would like to change images based on the current mode in the browser (light mode and dark mode) but it did not work. I have tried several ways to do this but to no avail. Only dark image is displayed but not the light image. I have used different browser, took a look for the prefers-color-scheme and my theme in global.css file but still ...
What I did was:
theme-image.module.css:
theme-image.tsx:
page.tsx
Do you have any solution for this?
Thank you very much