Please expose the dark mode API to plugins

Hi Figma team!

I’m working on the plugin Simple Icons. My idea is to keep my plugin the same theme as Figma’s main window.

I found it has data-preferred-theme="dark" on its body element. But I don’t know how to access it in a plugin.

Is there any API in plugin that can access the Figma’s main window?

If not, we might be able to expose an API for the dark mode. Like:

type Theme = 'light' | 'dark' | 'system'

interface PluginAPI {
  // ...
  readonly theme: Theme
  setTheme(theme: Theme): void

Seems the Plugin and Widget API is not open source. Please let me know if there is anything I can help with.

Thanks!

@tank666 Wow! Thank you so much! This is what I want!