How to use the Color Picker in Visual Studio Code

avatar
Borislav Hadzhiev

Last updated: Apr 6, 2024
3 min

banner

# How to use the Color Picker in Visual Studio Code

VS Code has a built-in color picker that is shown in CSS and HTML files.

You have to hover over the color with your mouse for the color picker to show up.

Here is a short clip that demonstrates how to use the color picker in a CSS file.

using color picker in css file

You can also use the color picker in HTML files.

using color picker in html file

You can click on the header to change the format of the color between:

  • rgba
  • hex
  • hsla
  • hwb

change format of color

If you can't get the color pick to show up in CSS and HTML files:

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type color decorators and make sure the Editor: Color Decorators setting is enabled.

enable editor color decorators

The Color Decorators setting controls whether the editor renders the inline color decorators and color pickers.

If the setting is disabled, the color picker is not shown at all.

Note that there is also an Editor: Color Decorators Limit setting.

The setting controls the maximum number of color decorators that are rendered in an editor at once.

The default value is 500 but you can increase it if you work with large files often.

If you notice that color decorators are not shown for some colors, then you are running over the limit.

# Using the Color Highlight extension

If you often work with CSS files, you should check out the Color Highlight extension.

  1. Click on Extensions in the left sidebar.
  • You can also open the Extensions menu by pressing:
    • Ctrl + Shift + X on Windows or Linux.
    • Command + Shift + X on macOS.
  1. Type color highlight and select the extension.

install color highlight extension

  1. Click on the Install button.

If you open a CSS file, you'll notice that your colors are styled in an easier to notice way.

extension styled colors in css file

This helps when looking for specific colors in large CSS files.

The extension also works for HTML files.

extension also styles colors in html files

You can also change the extension's settings and how colors are displayed:

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).
Note: you can also press F1 to open the Command Palette.
  1. Type user settings and select Preferences: Open User Settings.

open user settings

You can also open the settings screen by pressing Ctrl + , on Windows and Linux or Cmd + , on macOS.

  1. Type color highlight marker and check out the options from the dropdown menu.

color highlight marker type

For example, you can set the marker type to outline.

marker type outline

There is also an underline value.

marker type underline

By default, the colors are also shown in the sidebar.

colors are also shown in sidebar

If you want to disable this behavior, search for color highlight mark in your settings and disable the Color-highlight: Mark Ruler setting.

disable color highlight mark ruler

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.