-
Notifications
You must be signed in to change notification settings - Fork 27.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add light/dark mode theme detection to image component example #53760
chore: add light/dark mode theme detection to image component example #53760
Conversation
After merging, we should double check that https://image-component.nextjs.gallery/theme deployed properly. I set it up in #47130 to automatically deploy but its good to double check to avoid a broken link. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to document this or should it wait for the upcoming changes? It feels a bit strange to recommend the CSS display none change, felt like more of a hack than best practices, but maybe missing something.
Co-authored-by: Lee Robinson <[email protected]>
If you are referring to #51205, then I think it actually ends up being a lot more code and a lot more complex then the example in this PR. That is really only needed for Art Direction. We already know that CSS like this works because we've been using it in production for several years. So its best to document and explain how it works since this question comes up a lot. Furthermore, most apps that use dark/light mode already have detection outside the image, especially if they allow the user to toggle between light/dark because that would be stored in a cookie. So a simple media query may not be enough, but dynamic css is sufficient for all cases. |
…switching-for-nextimage
Co-authored-by: Lee Robinson <[email protected]>
…switching-for-nextimage
Follow up to #53760 This follows the same pattern as other demo links on this page.
This PR adds documentation for light/dark mode detection with
next/image
.In the future, we could also document the picture solution once #51205 goes stable (although preloading would still be a problem).