Skip to content

Get status theme mode realtime #3656

Answered by slorber
ghost asked this question in Q&A
Oct 29, 2020 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hi,

You'd rather remove the background of the image, or use 2 images but only show one according to current theme, using CSS instead of JS.

Using JS, it is not possible to know ahead of time (on the server/node/SSR process) what will be the theme of the user, so we can't choose between one image and another and would have to make a choice. If we show the white bg image on the static output, and then on hydration (js/react loaded in browser) show the black bg image, it would create jank, so you should avoid trying to do conditional image rendering based on theme using JS. You can do this with CSS however, because a theme class is added to the page even before the page paint, so it wouldn't…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jumpersdevice
Comment options

@slorber
Comment options

Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants