question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow CSS variables in themes

See original GitHub issue

It would be awesome if Monaco would allow any valid CSS value to be used for theme colors:

monaco.editor.defineTheme('mytheme', {
  colors: {
    'editor.background': 'var(--color-code-bg)',
  }
}

This currently fails the validation with this error:

Error: Illegal value for token color: var(--color-code-bg)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:8
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
joemaffeicommented, Dec 22, 2021

@silverwind

I think this method would only work for variables defined on CSS :root

You can get the computed style at the editor level. CSS variables cascade down no matter where they are declared.

const monacoRoot = document.querySelector('.monaco-editor');
const varnameValue = getComputedStyle(monacoRoot).getPropertyValue('--varname');
0reactions
yuval-hazazcommented, May 24, 2022

+1 for that. It would be very helpful to be able to manage all colors from one place

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create better themes with CSS variables
CSS variables differ from preprocessor variables in a number of ways. CSS variables are dynamic variables: Once set, their value is not fixed....
Read more >
The simplest CSS variable dark mode theme - Luke Lowrey
Using CSS variables for themes. CSS variables are properties you can set in your stylesheets that can be used in later styles. They...
Read more >
Dynamic theme with CSS Variables - Medium
Customize the theme with CSS variables. Enable theming with CSS variables is extremely simple and straightforward, with the following steps:.
Read more >
How to Create a Themes Engine Using CSS Variables and ...
To get a value defined on an element: const primary = getComputedStyle(element).
Read more >
Theming With CSS Variables - Prototypr
The easiest way is to use CSS variables — manage hundreds of places where you implemented different styles much better with a small...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found