Skip to content

Dark Mode interactions in v3 #3599

Discussion options

You must be logged in to vote

I'm a few years late to answer this but I came across this question while trying to figure it out for myself. So hope this helps if you still need it, or if anyone else, like me, ends up here looking for how to do this!

sanity exports useColorSchemeValue and useColorSchemeSetValue, that can be used to check and set theme state. I use something similar to this in my project:

import { useColorSchemeSetValue, useColorSchemeValue } from 'sanity'

const setSanityColourScheme = useColorSchemeSetValue()

const switchTheme = () => {
    const sanityColourScheme: "light" | "dark" = useColorSchemeValue()

    if (setSanityColourScheme)
        setSanityColourScheme(sanityColourScheme == 'light' ? '…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by julrich
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants