How to consume Plasmic global variants in own code?

Yes, we currently do not support that. But if you have a codegen app, you can register a global context to expose actions that could change global variants. Read Referencing ThemeContext/Global Variants in Plasmic Studio - #2 by jason

Here’s a detailed guide for loader usecase: Switching global variables doesn't work - #2 by sarah_ahmed