Skip to content

Highlight Colors

Highlight colors are named color values shared through ctx.highlightColors. Plugins can contribute colors for app surfaces such as subjects, decks, notes, and labels; the app decides where and how to render them.

Request the registry.highlight-color permission before using this registry:

{
"recall": {
"permissions": ["registry.highlight-color"]
}
}

A color contribution contains a stable id and the color value understood by the app. Use a namespaced id to avoid collisions with the app or another plugin.

const registration = await ctx.highlightColors.register([
{ id: "focus-tools.mint", value: "#10B981" },
{ id: "focus-tools.indigo", value: "#6366F1" },
]);

Ids are unique within a runtime context. register() rejects the complete registration if any submitted id is duplicated or already exists.

Keep the returned handle and dispose it when the plugin unloads:

await registration.dispose();

Disposal removes only the colors owned by that registration. You can also call remove(uid) when an individual color must be removed explicitly.

Use get() for one color and list() for a snapshot of all registered colors:

const mint = await ctx.highlightColors.get("focus-tools.mint");
const colors = await ctx.highlightColors.list();

Stored colors include id, value, and uid. The current registry uses the input id as its uid.

Subscribe when UI needs to react to palette changes:

const subscription = await ctx.highlightColors.on("listChange", ({ colors }) => {
renderColors(colors);
});
await subscription.dispose();

The runtime package also exports DEFAULT_HIGHLIGHT_COLORS, the palette used when the app does not provide initial colors:

import { DEFAULT_HIGHLIGHT_COLORS } from "@jrtilak-recall/runtime";