Search code examples
visual-studio-codevscode-extensions

visual studio code import custom css and js extension


I'd like to install custom styles in order to have different fonts for classes and attributes in visual studio code.

I installed the Custom CSS and JS Loader extension, and followed the guide but it doesn't seem to work.

Here's what I've tried. I created a file styles.css where I put this code:

.mtk1,
.mtk2,
.mtk8,
.mtk9,
.mtk10,
.mtk12,
.mtk11,
.mtk7,
.mtk3,
.mtk13,
.mtk16 {
  margin-left: 1px;
  font-family: "Indie Flower";
  font-size: 1em;

}

.mtk7,
.mtk4 {
  font-family: "Arial";
  font-size: 0.7em;
}

/*
For the tab titles.
*/
.monaco-icon-label-description-container .label-name {
  font-family: "Indie Flower";
  font-size: 1.3em;
}

.tabs-container .monaco-icon-label-description-container .label-name,
.sidebar .monaco-icon-label-description-container .label-name,
.quick-open-row .monaco-icon-label-description-container .label-name {
  font-family: -apple-system,BlinkMacSystemFont,Segoe WPC,Segoe UI,HelveticaNeue-Light,Ubuntu,Droid Sans,sans-serif;
  font-size: 1em;
}

Then in settings.json I added the following settings:

{
  "vscode_custom_css.imports": ["file:///home/mat/vscode_extensions/styles.css"],
  "vscode_custom_css.policy": true
}

I took the path by typing inside this directory pwd, so it should be correct path. However, it still doesn't want to apply styles, neither fontFamily nor fontSize.

Does anyone knows where the problem is?


Solution

  • You have to run VSCode as Administrator and then Enable CSS in JS.

    Example path to VSCode located in Applications: sudo /Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron

    And don't forget to install all those custom fonts to your Mac device.