Accessing global variants from interaction

Hey Team!
I’m playing around in the editor with global variants to theme a website differently.
I want to have a button to switch between global variants inside a set of global variants.
How can I access these global variants from an interaction? I guess with “Run Code”? But which code? Something like $state.global.set? Would appreciate some help!

Hi! At the moment there’s no built-in way of doing this :confused: You would have to run your own app (instead of using Plasmic hosting), have some React state at the root of your app for the global variant values, pass them into <PlasmicRootProvider globalVariants={{...}} , and wire up your toggle button to update the global variant value stored in your state :confounded:

Ah okay, I see, thank you for the response :blush:

This approach doesn’t work for me. Did you change anything in the implementation of global variants handling in @plasmicapp/loader-nextjs ?

Hello @se.belobrov, could you share more details on what’s not working for you? Are you seeing an error or unexpected behavior?