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.

[css] Use CSS custom properties imported via @import

See original GitHub issue

Is it possible for VS code to recognize CSS variables declared in a separate CSS file that is imported with @import ?

For example, I would like to have a variables.css file that is all about declaring CSS custom properties. Then I would import that file on top of my main css file, and be able to have intellisense support for those variables.

The way things work now, VSCode is not able to recognize those variables. Or maybe I am missing something obvious?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:119
  • Comments:25 (2 by maintainers)

github_iconTop GitHub Comments

18reactions
VitalyKrenelcommented, Mar 21, 2018

I vote for the feature too. It’s quite confusing when you can not find a variable within suggestions popup while it’s declared in one of the linked files, especially when it’s in :root pseudo-class (so it’s available throughout your project). Right now it’s appeared in suggestions popup only in the file where the custom property is defined.

It would be great if the popup could show on typing -- not only the variable’s name and value but also some kind of modifier that explains where the variable is declared: in :root, inherited from parent or it comes right from this selector where it’s used (probably in terms of sorting this kind of custom properties should have higher priority). Also, the modifier mentioning overriding (‘Root value is overridden in ‘name’ selector’ or something like this) would be useful.

15reactions
JoshMayberrycommented, Mar 2, 2020

How do I cast my vote for this feature? I am very interested in it as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

import - CSS: Cascading Style Sheets - MDN Web Docs
The @import CSS at-rule is used to import style rules from other valid stylesheets. An @import rule must be defined at the top...
Read more >
Importing global css custom variables - Stack Overflow
Basically I want any css that imports theme-variable to be able to access these css custom properties and resolve to static values using...
Read more >
CSS @import Rule - W3Schools
@import url("navigation.css"); /* Using a url */ ... The numbers in the table specify the first browser version that fully supports the property....
Read more >
CSS Custom Properties (vars) with SASS/SCSS, a practical ...
CSS Custom Properties (vars) with SASS/SCSS, a practical architecture strategy · When using a prefixed CSS Custom Prop with SCSS you have to...
Read more >
CSS Variables for React Devs - Josh W Comeau
The thing that makes CSS variables different from typical CSS properties is that we can access their values, using the var() function. This...
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