agentleFS
MicrosoftKnown publishermicrosoft/vscode/.github/skills/ux-theming/SKILL.md

ux-theming

Skill196k starsChanged 17 days agoMITView on GitHub

VS Code theming, color tokens, composited surfaces, interaction-state precedence, and high-contrast support. Use when styling widgets, changing hover/focus/selection, or validating rendered theme states.

Trending

More talk lately.about the whole repository

Dec 2025: 2 mentionsJan 2026: 1 mentionFeb 2026: 1 mentionMar 2026: 1 mentionApr 2026: 2 mentionsMay 2026: 4 mentionsJun 2026: 2 mentionsJul 2026: 2 mentionsAug 2026: 0 mentionsSep 2026: 3 mentionsOct 2026: 1 mentionNov 2026: 2 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the microsoft/vscode repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about microsoft/vscode

The biggest 5 of 96 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 96

Talked about on Bluesky, Hacker News and GitHub (96 times).

On Bluesky · 48

43 more on Bluesky

On Hacker News · 39

34 more on Hacker News

On GitHub · 9

4 more on GitHub

The file

Show its rules and text

We split this skill into the rules it gives an agent

18 rules. About 0 are common, 13 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈13

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use color transforms for derived colors: transparent(), darken(), lighten(), oneOf().

    line 23
  2. Distinctive:

    Treat foreground and background as a semantic pair.

    line 64
  3. Distinctive:

    Check nested labels and descriptions in combined states.

    line 67
  4. Distinctive:

    Keep material paint separate from interactive descendants.

    line 74
  5. Distinctive:

    Every widget type has a default style object and an override factory:

    line 80
  6. Distinctive:

    Use the owning theme service for temporary palettes so CSS variables and programmatic color consumers remain consistent.

    line 96
  7. Distinctive:

    Verify enabling, disabling, replacement, disposal, and theme changes, including stale asynchronous results.

    line 98
  8. Distinctive:

    Before changing a color fallback, distinguish the registered default, an explicit theme value, a user customization, and a temporary …

    line 102
  9. Distinctive:

    Do not infer explicit theme intent from a resolved color alone: resolution may include registry defaults or transient overlays.

    line 105
  10. Distinctive:

    Keep independent semantic roles independently customizable.

    line 106
  11. Very specific:

    Use var(--vscode-focusBorder) — never hardcode a focus color.

    line 126
  12. Very specific:

    Default outline-offset: -1px (inset).

    line 127
  13. Very specific:

    Check keyboard focus independently from selection and hover, including ordinary links without explicit tabindex and icon-only controls.

    line 130
  14. Distinctive:

    Box shadows: must be removed or replaced in HC mode (shadows are invisible/distracting with high contrast borders):

    line 148
  15. Distinctive:

    Test runtime theme changes and custom color overrides, including transitions where a previously defined token becomes absent.

    line 199
  16. Distinctive:

    When exact theme colors are the contract, load and assert those tokens.

    line 206
  17. Distinctive:

    Follow the fixture contract checks for readiness, idle, and remount.

    line 210
  18. Very specific:

    Rule: If a value relates to color, shadow, or border — it must come from a CSS variable or registered color token.

    line 229

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

This skill covers color registration, CSS variable usage, widget style patterns, focus indicators, and high-contrast theme requirements.


1. Registering Colors

File: src/vs/platform/theme/common/colorUtils.ts

export const myWidgetBackground = registerColor('myWidget.background',
    { light: '#ffffff', dark: '#252526', hcDark: Color.black, hcLight: Color.white },
    nls.localize('myWidgetBackground', "Background color of My Widget."));

Rules:

  • Provide defaults for all four theme types: light, dark, hcDark, hcLight.
  • HC themes must use solid colors (avoid transparency) and set explicit borders via contrastBorder.
  • Use color transforms for derived colors: transparent(), darken(), lighten(), oneOf().
  • Reference existing colors when possible instead of hardcoding hex values.

2. Color Categories

FileColors
src/vs/platform/theme/common/colors/baseColors.tsforeground, focusBorder, contrastBorder, text links
src/vs/platform/theme/common/colors/editorColors.tsEditor widgets, find match, errors/warnings
src/vs/platform/theme/common/colors/inputColors.tsInput, toggle, validation
src/vs/platform/theme/common/colors/listColors.tsList/tree selection, focus, hover, drop
src/vs/platform/theme/common/colors/miscColors.tsBadge, scrollbar, progress bar, sash
src/vs/workbench/common/theme.tsTabs, sidebar, status bar, panels, editor groups, banner

3. Using Colors in CSS

Colors are injected as CSS custom properties on .monaco-workbench:

Color ID: editor.background
CSS variable: --vscode-editor-background
Usage: var(--vscode-editor-background)

Conversion functions in colorUtils.ts:

  • asCssVariable(colorId) → 'var(--vscode-editor-background)'
  • asCssVariableName(colorId) → '--vscode-editor-background'

In CSS files, reference directly:

.my-widget {
    background-color: var(--vscode-editor-background);
    color: var(--vscode-foreground);
    border: 1px solid var(--vscode-contrastBorder);
}

Trace the rendered control before choosing a token or selector; custom editor overlays may not use native input pseudo-elements. Inspect inherited and nested styles as well as the component's own declarations.

Contrast and Interaction States

  • Treat foreground and background as a semantic pair. A background change requires checking text, placeholders, links, operable inactive icons, hover, selection, and focus against the final composited surface.
  • Resolve defaults, opacity, and user overrides before measuring contrast. For example, an opaque icon color may meet contrast requirements while its translucent inactive variant does not.
  • Normal-size text and placeholders need at least 4.5:1 contrast; visual information needed to identify controls and focus needs at least 3:1 against adjacent colors. Apply the relevant accessibility criteria rather than extending these thresholds to decorative or disabled content. Unselected but operable controls are not disabled.
  • Check nested labels and descriptions in combined states; an explicit child foreground can defeat a correctly paired selection background.
  • Choose tokens by semantic role, not their current hue. A chart accent is not automatically a warning-button background, and pairing it with a default button foreground does not establish contrast. Reuse an appropriate control palette or register a themeable foreground/background pair when the component has its own semantics.

Composited Surfaces

A theme variable is not necessarily opaque. For a floating panel that must conceal underlying content, inspect the resolved alpha and all material layers rather than assuming a panel token or var() fallback guarantees occlusion. Use the owning theme/color helpers to derive an opaque semantic background where needed, preserve the intended glass treatment elsewhere, and verify switching content and floating/docked modes on the same instance.

Keep material paint separate from interactive descendants. Border-box and padding-box alignment, clipping, and duplicated translucent strokes are covered by rounded-surface geometry.

4. Widget Styles Pattern

File: src/vs/platform/theme/browser/defaultStyles.ts

Every widget type has a default style object and an override factory:

// Use defaults:
const button = new Button(container, defaultButtonStyles);

// Override specific colors:
const button = new Button(container, getButtonStyles({
    buttonBackground: myCustomBackgroundColor
}));

Available defaults: defaultButtonStyles, defaultInputBoxStyles, defaultCheckboxStyles, defaultToggleStyles, defaultDialogStyles, defaultListStyles, defaultSelectBoxStyles, defaultMenuStyles, defaultProgressBarStyles, defaultCountBadgeStyles, defaultBreadcrumbsWidgetStyles, defaultKeybindingLabelStyles, defaultFindWidgetStyles.

Transient Theme Overrides

Use the owning theme service for temporary palettes so CSS variables and programmatic color consumers remain consistent. Keep overrides scoped to the intended window and preserve the base theme and user customizations.

Verify enabling, disabling, replacement, disposal, and theme changes, including stale asynchronous results. Clearing an override must restore the original colors without persisting generated values or changing another window's theme or startup colors.

Color provenance and consumer coverage

Before changing a color fallback, distinguish the registered default, an explicit theme value, a user customization, and a temporary overlay. They are not interchangeable:

  • Preserve the owning component's precedence contract. Adding a theme default can bypass an existing fallback to a user-customizable legacy token; test no customization, legacy-only customization, and both legacy and new tokens using the loaded theme.
  • Do not infer explicit theme intent from a resolved color alone: resolution may include registry defaults or transient overlays. A fix for an active-tab theme color must not automatically change inactive, hover, or transparent-action compositing.
  • Keep independent semantic roles independently customizable. For example, hiding editor diagnostic squiggles with transparent user colors must not hide Debug Console messages; preserve explicit console overrides and theme-defined diagnostic defaults.
  • Trace every paint path. A scoped CSS variable does not update a theme-service lookup, an inline concrete color, a terminal canvas, or a detached Test Results terminal. Use the owning shared resolver where appropriate and subscribe affected consumers to the real runtime invalidation.
  • For a new border color, check border presence, style, width, and layout reservation as well as color. A correctly resolved color cannot paint a border whose owner sets none or zero width. Include themes where the old border token is absent.
  • Validate moved views in both sidebars and the panel, preserving their location-specific and peek palettes. Use strongly contrasting test colors so an old-colored embedded surface cannot pass unnoticed.
  • Measure the actual painted state and token: a horizontal Activity Bar uses different foreground tokens from the vertical bar; opacity and underlying surfaces affect the result. A faint selection fill does not prove that its boundary remains distinguishable.

5. Focus Indicators

Defined in src/vs/workbench/browser/media/style.css:

.my-widget:focus-visible {
    outline-width: 1px;
    outline-style: solid;
    outline-offset: -1px;
    outline-color: var(--vscode-focusBorder);
}

Rules:

  • Use var(--vscode-focusBorder) — never hardcode a focus color.
  • Default outline-offset: -1px (inset). Exception: checkboxes use 2px.
  • Preserve the owning widget's keyboard-focus mechanism, including supported .focus-visible or .synthetic-focus classes. Pointer activation should not leave an unnecessary keyboard ring, but broad :active suppression must not erase the boundary during keyboard activation.
  • Toggle selection, pointer hover, and keyboard focus are different states; do not use a dashed focus border as a universal toggle rule. Follow the interaction-state contract.
  • Check keyboard focus independently from selection and hover, including ordinary links without explicit tabindex and icon-only controls. Inspect computed outlines and pseudo-elements under production styles; token registration alone does not establish visibility.
  • Preserve a clear focus boundary through clipping and modal wrappers. Resolve competing border/outline ownership rather than adding duplicate rings or removing focus visibility.

Focus Trapping

Modal dialogs must trap focus within the dialog until dismissed. Use dom.trackFocus() and handle Tab/Shift+Tab cycling.

6. High Contrast Theme Rules

  • Always provide hcDark and hcLight defaults when registering colors.
  • HC surface backgrounds: use the registered HC defaults, commonly Color.black (hcDark) and Color.white (hcLight). Preserve component-specific selection and control palettes.
  • HC borders: reference contrastBorder — it is null in normal themes, visible in HC.
  • HC keyboard focus: use focusBorder or the owning list's focus token; reserve contrastActiveBorder for the interaction states below.
  • In CSS, use .hc-black / .hc-light class selectors for HC-specific overrides:
    .hc-black .my-widget { border: 1px solid var(--vscode-contrastBorder); }
  • In TypeScript, check isHighContrast(theme.type) for runtime behavior changes.
  • Box shadows must be removed or replaced in HC mode (shadows are invisible/distracting with high contrast borders):
    .my-widget {
        box-shadow: 0 1px 3px var(--vscode-widget-shadow);
    }
    .monaco-workbench:is(.hc-black, .hc-light) .my-widget {
        box-shadow: none;
        border: 1px solid var(--vscode-contrastBorder);
    }

High-Contrast Interaction-State Contract

Interaction boundaries communicate different semantics. Do not collapse hover, keyboard focus, selection, and persistent state into one generic rule.

StateBoundaryRequired behavior
Pointer hoverDashed contrastActiveBorderApply only to the actionable element actually under the pointer. A mouse-navigation class plus a stale focused row is not sufficient.
Keyboard focusSolid focusBorder or the owning list focus tokenMust win over simultaneous hover and open/expanded/pressed state. Preserve the focus ring when the pointer remains over the control.
Open, expanded, or pressedSolid contrastActiveBorderPersistent state, not transient hover. Keep normal-theme hover fill separate so an expanded control can respond to the pointer without becoming dashed.
Selected or checkedThe component's selection palette and semantic foregroundHover must not replace the selected background while leaving the selected foreground behind.
DisabledNo hover or active boundaryDisabled styling remains owned by the component. A disabled control that intentionally remains keyboard-focusable still needs a focus indicator.

Assign one boundary owner per interaction. A pseudo-element may paint an inset hover fill, but it must not also draw an outline when the component root owns the boundary. When a card contains independent actions, suppress the card boundary while a nested action is hovered, focused, or open. For virtualized trees, inspect both the .monaco-list-row and its painted child such as .monaco-tl-row; never clear the child focus ring when the outer row's outline is intentionally suppressed.

Native disclosure state is not exposed as aria-expanded on <summary>. Use details[open] > summary for visual state, or synchronize a component state class/ARIA attribute for a non-native disclosure. Exclude keyboard focus from persistent-state rules as well as hover rules; greater selector specificity can otherwise erase focus even when the focus rule comes later.

For a custom control whose expanded/pressed state uses ARIA, keep background and boundary selectors independent. This example preserves keyboard precedence in combined states:

.control:not(.disabled, :disabled, [aria-disabled='true']):is(:hover, .hovered) {
	background-color: var(--vscode-list-hoverBackground);
}

.monaco-workbench:is(.hc-black, .hc-light) .control:not(.disabled, :disabled, [aria-disabled='true'], :focus-visible, .focus-visible, [aria-expanded='true'], [aria-pressed='true']):is(:hover, .hovered) {
	outline: var(--vscode-strokeThickness) dashed var(--vscode-contrastActiveBorder);
}

.monaco-workbench:is(.hc-black, .hc-light) .control:not(:disabled):is(:focus-visible, .focus-visible) {
	outline: var(--vscode-strokeThickness) solid var(--vscode-focusBorder);
}

.monaco-workbench:is(.hc-black, .hc-light) .control:not(.disabled, :disabled, [aria-disabled='true'], :focus-visible, .focus-visible):is([aria-expanded='true'], [aria-pressed='true']) {
	outline: var(--vscode-strokeThickness) solid var(--vscode-contrastActiveBorder);
}

For controls with a selected/checked palette, exclude that state from the generic hover fill or provide its correctly paired selected-hover colors. Keep independent status markers distinct as well: attention-required, pinned, selected, and focused states can coexist. Test their combined placement and semantic foregrounds rather than letting a new marker cover an existing one.

Validate a state matrix rather than isolated screenshots: rest, hover, keyboard focus, focus plus hover, open/expanded/pressed plus focus and hover, selected/checked plus hover, disabled plus hover, intentionally focusable-disabled focus, and nested-action focus/hover. Load all production styles that compete for the boundary and verify both HC Dark and HC Light, plus normal Dark/Light when selector exclusions can affect hover fills.

Test runtime theme changes and custom color overrides, including transitions where a previously defined token becomes absent. Clear stale inline colors or classes rather than leaving the previous theme's state behind. Render through production state-owning services so intentionally omitted decoration remains absent.

Testing Rendered Interaction States

  • A dispatched mousemove can update a widget's modality or logical focus without activating CSS :hover. Use real pointer input for interaction tests. A fixture may use the production-supported .hovered class, but it must assert the intended computed boundary before capturing a screenshot.
  • Establish keyboard modality through the actual input path, then dispatch navigation from the focused item. An ancestor bubbling listener may never see keys consumed by an inner ActionBar; use capture only where the owner must observe the event before that handler. Test pointer-to-keyboard transitions with a stationary pointer.
  • Do not assume .focus() or a synthetic key event makes :focus-visible true in every browser or Electron host. Control the fixture's supported focus state or drive actual keyboard input, isolate previous focus, and verify the state before asserting styles. Do not skip a failed focus assertion or weaken it to mere activeElement equality.
  • When exact theme colors are the contract, load and assert those tokens. When preserving platform styling is the contract, assert a visible nonzero focus boundary instead of an unrelated hardcoded color. Include the relevant production stylesheet cascade in either case.
  • Exercise both forced-focus and natural-focus fixture modes. Wait for a focus-triggered hover only when focus was actually requested. Check readiness, idle, and remount so an async tooltip is not captured accidentally or awaited forever.
  • In missing-token tests, distinguish local removal from inherited values. If an ancestor supplies the property, use a scoped guaranteed-invalid value such as a self-reference to exercise var() fallback without changing global theme state. Verify computed behavior rather than accepting a reviewer's suggested CSS keyword untested. A fallback does not repair a defined value with the wrong CSS type.
  • Hit-test the intended action region, allowing the hit element to be the control or one of its descendants, then activate it and assert the behavior or ARIA change. Exact root equality is brittle; CSS styling alone does not prove that labels, chevrons, or edge padding remain clickable.
  • Follow the fixture contract checks for readiness, idle, and remount. Keep production behavior tests at the owning production API.

7. No Hardcoded Visual Values

Reviewers will always flag hardcoded colors, shadows, sizes that should use theme tokens or CSS variables.

Hardcoded (flagged)Correct
rgba(0, 0, 0, 0.12)var(--vscode-widget-shadow) or theme-aware variable
#252526var(--vscode-editor-background)
color: whitevar(--vscode-button-foreground)
border: 1px solid #cccvar(--vscode-editorWidget-border)
border: 1px solid … (width)var(--vscode-strokeThickness) for the 1px width
border-radius: 6pxvar(--vscode-cornerRadius-medium) (radius ramp)
padding: 8px 12px (off-scale)spacing ramp (--vscode-spacing-size*)
font-size: 14px (arbitrary)size ramp (--vscode-fontSize-*)
font-weight: 500--vscode-fontWeight-semiBold (no 500)
codicon font-size: 14px--vscode-codiconFontSize (16) / -compact (12)

Rule: If a value relates to color, shadow, or border — it must come from a CSS variable or registered color token. The only exception is 0 (zero) values and purely structural measurements like 100%.

Size, spacing, radius, font and stroke values have their own design-system size tokens (and decision logic — snap maps, the pill→circle rule, and the compact-glyph convention). Those live in the ux-css-layout skill (§10 Design-System Size Tokens) and the auto-injected .github/instructions/design-tokens.instructions.md. Reach for those when a flag is about how big / how round / how bold something is rather than what color.


Key Files

AreaFile
Color registrationsrc/vs/platform/theme/common/colorUtils.ts
Color registry (barrel)src/vs/platform/theme/common/colorRegistry.ts
Base colorssrc/vs/platform/theme/common/colors/baseColors.ts
Workbench colorssrc/vs/workbench/common/theme.ts
Default widget stylessrc/vs/platform/theme/browser/defaultStyles.ts
Global workbench stylessrc/vs/workbench/browser/media/style.css

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.