Detect light/dark theme programmatically in Visual Studio Code
Visual Studio Code 1.3 added this feature:
When previewing html, we expose the style of the current theme via class names of the body element. Those are vscode-light, vscode-dark, and vscode-high-contrast.
Inspecting for one of these values using JavaScript allows customisation of the preview stylesheet to match the active theme in the editor.