UX4G Design System Extension
Note: This is not an official UX4G extension. I built it for my own use, to make working with UX4G easier.
Editor support for the UX4G design system in VS Code, Cursor,
Antigravity and other VS Code based editors.
- Hover a design token to see its final value, without opening the stylesheet.
- Ctrl+Click (or F12) a token or class to jump to where it is defined.
- Your overrides win. If your project redefines a token, hover and Ctrl+Click show your value, not the package default.
It reads the ux4g-web-components package installed in your project, so it always matches the version you use.
Features
Token values on hover
Semantic tokens point to other tokens. The hover follows the references to the end and shows every step:
--ux4g-bg-neutral → var(--ux4g-color-neutral-50) → #fafafa
ux4g-web-components · :root · @layer ux4g-semantics
- ux4g-web-components ·
.dark,:root[data-mode=dark],[data-mode=dark] · @layer ux4g-semantics: #171717
- Hex colours get a colour swatch.
- Up to three other definitions (dark mode, scoped rules) are listed with their final values.
calc() and other composite values have every var() replaced.
Go to definition
| You Ctrl+Click |
You land on |
A class, ux4g-btn |
Its rule in the package stylesheet |
A token, --ux4g-btn-radius |
Your override if there is one, otherwise the package definition |
| Your own override |
The package definition it replaces |
The package ships one minified stylesheet, so the extension opens a formatted, read-only copy of it
(ux4g-web-components@<version>/ux4g.css).
Works where you write UX4G
HTML, CSS, SCSS, LESS, JSX, TSX, Vue, Svelte, Astro and any other file type.
Requirements
ux4g-web-components installed from npm in your project:
npm install ux4g-web-components
Projects that load UX4G only from the CDN get hover and Ctrl+Click for their own overrides, not for the package.
Install
VS Code: open the Extensions view (Ctrl+Shift+X) and search for UX4G Design System Extension.
Cursor, Antigravity, Windsurf, VSCodium: these editors use the Open VSX registry. Search for
UX4G Design System Extension in their Extensions view.
From a file (any of the editors above):
- Download the
.vsix from the latest release.
- Open the Extensions view, click
… at the top, choose Install from VSIX… and pick the file.
Or from a terminal:
code --install-extension ux4g-design-system-0.3.0.vsix
Extensions installed from a file do not update automatically.
How a target is chosen
Tokens
- Overrides are
--ux4g-* declarations in your .css, .scss and .less files and in <style> blocks of
.html, .vue, .svelte and .astro files. Unsaved edits count.
- If there are overrides, only they are offered: same file first, then the nearest folder. Several overrides open
the peek list.
- With no override, the package definitions are offered, the plain
:root one first.
Classes
Rules that style exactly that class are offered. If there are none, rules whose subject carries the class; failing
that, every rule that mentions it.
Package
The nearest node_modules/ux4g-web-components above the file you are editing, the way Node resolves it. Monorepos
with several versions get the right one per file.
Limits
- Override order is by file distance, not the real CSS cascade, which depends on the page's DOM.
- Overrides set from JavaScript (
style.setProperty) or inline style attributes are not indexed.
node_modules, dist, build, out, coverage, .git, .next, .nuxt and .svelte-kit are not searched
for overrides.
New versions of ux4g-web-components
Nothing to do in the extension. Update the package in your project and the next hover or Ctrl+Click reads the new
stylesheet.
Development
npm install
npm test # unit tests for the core logic
npm run test:vscode # runs hover and go to definition inside VS Code against test/fixture
npm run package # builds the .vsix
src/core has no VS Code dependency: walk.ts finds rule boundaries, format.ts and scan.ts build on it,
resolve.ts picks targets and hover.ts follows token references.
Author
Developed by KASIF Raza
Found a bug or a token that resolves wrongly? Open an issue.
License
MIT