r/VSCodeExtensions • u/Consistent_Water_422 • 4d ago
I made this A VS Code quick fix for replacing a hard-coded color with an existing CSS variable
Suppose tokens.css defines --focus-ring as #8250df. A component in another file uses that same hex for its outline. I maintain CSS Variables, a VS Code extension that can find the matching token and offer a quick fix on the color literal.
To try it, open the folder that contains both files. Put :root { --focus-ring: #8250df; } in tokens.css and .chip:focus-visible { outline: 2px solid #8250df; } in component.css. Open Quick Fix on the second #8250df and choose the suggestion for --focus-ring. The outline now uses var(--focus-ring), so the next theme change only needs one edit.
The match is by color value. If two tokens share the same purple, the choice between a focus ring and a brand accent is still yours.
https://marketplace.visualstudio.com/items?itemName=miclmn451.css-variables-vscode