/vs-extensibility-skills:registering-fonts-colorsfrom vs-extensibility-skills
Registers custom font and color categories in Visual Studio extensions, enabling user-customizable display items via Tools > Options > Fonts and Colors.
Ships in vs-extensibility-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Extensions can register custom font and color categories that appear on the Tools > Options > Environment > Fonts and Colors page. Users can then customize foreground, background, and font styles for each item your extension defines.
This is different from general theming (matching VS's Light/Dark theme). This is about letting users customize your extension's display items — like a custom editor's syntax colors.
Registering custom Fonts & Colors items gives users control over your extension's visual appearance through the standard VS settings page they already know. Without it, your extension either hard-codes colors (which break in different themes) or requires its own custom settings UI. Fonts & Colors entries also integrate with the VS theme system — they can have default values per theme (Light, Dark, High Contrast) that VS applies automatically when the user switches themes.
When to use this vs. alternatives:
The toolkit wraps the complex VSSDK registration with three building blocks:
BaseFontAndColorCategory<T> — defines a category with its default font and color items.BaseFontAndColorProvider — discovers categories and serves them to Visual Studio.VS.FontsAndColors — reads the user's configured colors at runtime.NuGet package: Community.VisualStudio.Toolkit
Key namespace: Community.VisualStudio.Toolkit
Create a class inheriting from BaseFontAndColorCategory<T>. Give it a unique [Guid], a display Name, and one or more ColorDefinition properties.
using System.Runtime.InteropServices;
using Community.VisualStudio.Toolkit;
using Microsoft.VisualStudio.Shell.Interop;
[Guid("e977c587-c06e-4c1d-8a3a-cbf9da1bdafa")]
public class MyColorCategory : BaseFontAndColorCategory<MyColorCategory>
{
// Default font. Use FontDefinition.Automatic to inherit the user's editor font.
public MyColorCategory() : base(new FontDefinition("Consolas", 10)) { }
// This name appears in the category drop-down on the Fonts and Colors page.
public override string Name => "My Extension Colors";
public ColorDefinition Keyword { get; } = new(
"Keyword",
defaultForeground: VisualStudioColor.Indexed(COLORINDEX.CI_BLUE),
defaultBackground: VisualStudioColor.Automatic()
);
public ColorDefinition Comment { get; } = new(
"Comment",
defaultForeground: VisualStudioColor.Indexed(COLORINDEX.CI_DARKGREEN),
defaultBackground: VisualStudioColor.Automatic(),
fontStyle: FontStyle.Italic
);
public ColorDefinition Error { get; } = new(
"Error",
defaultForeground: VisualStudioColor.Indexed(COLORINDEX.CI_RED),
defaultBackground: VisualStudioColor.Automatic(),
fontStyle: FontStyle.Bold
);
}
Each ColorDefinition property is automatically discovered. The name parameter passed to the constructor is what appears on the options page.
| Factory method | Description |
|---|---|
VisualStudioColor.Indexed(COLORINDEX.CI_*) | Standard VS color index |
VisualStudioColor.VsColor(__VSSYSCOLOREX.VSCOLOR_*) | VS themed system color |
VisualStudioColor.Automatic() | Let VS choose based on the current theme |
Control what the user can customize:
public ColorDefinition Literal { get; } = new(
"Literal",
defaultForeground: VisualStudioColor.Indexed(COLORINDEX.CI_MAROON),
options: ColorOptions.AllowForegroundChange | ColorOptions.AllowBoldChange
);
Create a class inheriting from BaseFontAndColorProvider. It needs its own [Guid]. The provider automatically discovers all BaseFontAndColorCategory<T> classes in the same assembly.
[Guid("26442428-2cd7-4d79-8498-f9b14087ca50")]
public class MyFontAndColorProvider : BaseFontAndColorProvider { }
Add the [ProvideFontsAndColors] attribute to your package class and call RegisterFontAndColorProvidersAsync() during initialization.
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[Guid(PackageGuids.MyPackageString)]
[ProvideFontsAndColors(typeof(MyFontAndColorProvider))]
public sealed class MyPackage : ToolkitPackage
{
protected override async Task InitializeAsync(
CancellationToken cancellationToken,
IProgress<ServiceProgressData> progress)
{
await this.RegisterFontAndColorProvidersAsync();
}
}
ConfiguredFontAndColorSet config =
await VS.FontsAndColors.GetConfiguredFontAndColorsAsync<MyColorCategory>();
// Read the current font
ConfiguredFont font = config.Font;
string fontFamily = font.FamilyName;
ushort fontSize = font.Size;
// Read a specific color
MyColorCategory category = MyColorCategory.Instance;
ConfiguredColor keywordColor = config.GetColor(category.Keyword);
System.Drawing.Color foreground = keywordColor.ForegroundColor;
System.Drawing.Color background = keywordColor.BackgroundColor;
The returned ConfiguredFontAndColorSet is live — it raises change notifications when the user modifies colors while your extension is running.
// The ConfiguredFontAndColorSet always reflects the latest user choices.
// Re-read colors whenever you need to repaint.
ConfiguredColor latest = config.GetColor(category.Keyword);
The VSSDK requires implementing IVsFontAndColorDefaults and registering via the registry.
NuGet package: Microsoft.VisualStudio.SDK
Key namespaces: Microsoft.VisualStudio.Shell.Interop, Microsoft.VisualStudio.Shell
Your VSPackage must implement IVsFontAndColorDefaultsProvider and return an IVsFontAndColorDefaults instance for each category GUID.
Each IVsFontAndColorDefaults implementation must provide:
In your .pkgdef or via registry attributes:
[$RootKey$\FontAndColors\My Extension Colors]
"Category"="{e977c587-c06e-4c1d-8a3a-cbf9da1bdafa}"
"Package"="{your-package-guid}"
IVsFontAndColorStorage storage = (IVsFontAndColorStorage)
GetService(typeof(SVsFontAndColorStorage));
Guid categoryGuid = new Guid("e977c587-c06e-4c1d-8a3a-cbf9da1bdafa");
storage.OpenCategory(ref categoryGuid, (uint)__FCSTORAGEFLAGS.FCSF_READONLY);
ColorableItemInfo[] itemInfo = new ColorableItemInfo[1];
storage.GetItem("Keyword", itemInfo);
uint foreground = itemInfo[0].crForeground;
storage.CloseCategory();
Implement IVsFontAndColorEvents or poll via IVsFontAndColorStorage. Use IVsFontAndColorCacheManager to flush stale caches before reading.
Note: The raw VSSDK approach is significantly more boilerplate than the toolkit. Use the Community Toolkit's
BaseFontAndColorCategory<T>when possible.
The VisualStudio.Extensibility SDK does not currently provide an API for registering custom Fonts and Colors categories. This feature requires in-process registration via COM interfaces.
If you need Fonts and Colors support from an out-of-process extension, use a mixed in-proc/out-of-proc extension pattern with an in-process companion that handles the registration.
[ProvideEditorFormatDefinition] or [ProvideFontAndColorsCategory] attributes are present on your package. For classifications, ensure [UserVisible(true)] is set on the ClassificationFormatDefinition.ThemeResourceKey to specify different defaults for Light, Dark, and High Contrast.IVsFontAndColorEvents to get notified when settings change.Do NOT hard-code RGB color values without per-theme defaults — colors that look good in Light can be invisible in Dark or High Contrast.
Do NOT create your own color-picker settings UI — use the VS Fonts & Colors infrastructure.
Do NOT use
System.Drawing.ColororSystem.Windows.Media.Colordirectly in WPF — useThemeResourceKeyor VS color service bindings.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
visual-studio-extension, fonts-and-colors, vsix, vssdk, theming
Generated from the plugin's indexed repository (madskristensen/vs-agent-plugins) — no native marketplace selected
npx claudepluginhub p/madskristensen-vs-extensibility-skills41 skills in this plugin
/adding-codelens-indicatorsAdd custom CodeLens indicators that display inline information above code elements in the Visual Studio editor. Use when the user asks how to add a CodeLens indicator, show inline data above methods or classes, create a custom CodeLens provider, implement IAsyncCodeLensDataPointProvider, display git history or test status in CodeLens, or add a details popup to CodeLens entries. Covers VSSDK / VSIX Community Toolkit (in-process + out-of-process CodeLens service). VisualStudio.Extensibility (out-of-process) does not have a dedicated CodeLens API./adding-commandsAdd commands (menu items, toolbar buttons) to Visual Studio extensions. Use when the user asks how to create a command, add a menu item, add a toolbar button, register a command handler, wire up a .vsct file, use KnownMonikers icons on buttons, or place commands in menus/toolbars in a Visual Studio IDE extension. Covers VisualStudio.Extensibility (out-of-process), VSIX Community Toolkit (in-process), and legacy VSSDK (in-process) approaches./adding-context-menusAdd native-looking context menus to custom WPF UI in Visual Studio extensions (tool windows, custom tree views, list views). Use when the user wants to show a right-click context menu from their own UI that looks native to VS. Covers defining VSCT context menus (type="Context"), grouping commands with separators, and programmatically showing them via IVsUIShell.ShowContextMenu. Do NOT use regular WPF ContextMenu — it won't match VS theming or support command routing. Covers VSSDK and VSIX Community Toolkit (in-process). VisualStudio.Extensibility (out-of-process) does not support VSCT-based context menus on custom UI.Other plugins' skills for the same job