---
name: extending-vela-with-plugins
description: Extends Vela charts through the public plugin SDK (@luxalgo/vela/plugin) - topbar buttons and right-click menu rows (registerWidgetAction), overlays and per-chart behavior (registerWidgetAttachment), docked side panels (registerSidePanel), custom chart types, renderer layers, native indicators, legend actions, drawing actions, saved state and shell defaults. Use when adding a feature, button, menu entry, panel, overlay or chart style to a Vela chart or VelaWorkspace, or packaging such features as a plugin, instead of forking Vela or reaching into its DOM.
license: Apache-2.0
title: extending-vela-with-plugins
canonical_url: https://skilld.dev/gh/luxalgo/vela/extending-vela-with-plugins
last_updated: 2026-11-18T06:08:22.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install luxalgo/vela/extending-vela-with-plugins`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/extending-vela-with-plugins`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/luxalgo/vela/extending-vela-with-plugins) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/extending-vela-with-plugins`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/extending-vela-with-plugins --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/extending-vela-with-plugins --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Extending Vela with plugins

Everything below comes from `@luxalgo/vela/plugin`. A plugin contributes **descriptors** (data)
and Vela projects them into its chrome; it never edits Vela's DOM.

## Pick the hook

| To add | Hook |
| --- | --- |
| A topbar button, or a row in the chart, price-axis or time-axis right-click menu | `registerWidgetAction` (`target: 'topbar'`, `'context:body'`, `'context:price-axis'`, `'context:time-axis'`) |
| An overlay, a gesture, key handling: behavior mounted once per chart app | `registerWidgetAttachment` |
| A docked panel on the right, with its own toggle button | `registerSidePanel` |
| A full-width strip or a rail at the edge | `ctx.dockStrip(el)`, `ctx.dockEdge(el, 'right')` from an action or attachment |
| A new chart style (in the style menu) | `registerChartType` (`supports(facts)` greys it on a symbol it cannot draw) |
| Drawing on the chart canvas | `registerRendererLayer` |
| A computed study without a script | `registerNativeIndicator` |
| Buttons or badges on legend rows | `registerLegendAction`, `registerLegendCallout` |
| A button on a selected drawing's toolbar and settings dialog | `registerDrawingAction` (`when(drawing)`, `run(ctx, drawing)`) |
| State saved with the chart's document | `registerStatePersistence` |
| A default for every shell (the sidebar on) | `registerShellDefaults` |
| A scripting language for every chart | `registerDefaultEngine` |

## Example: a menu row and a panel that follows the symbol

```ts
import { msg, registerIcon, registerSidePanel, registerWidgetAction } from '@luxalgo/vela/plugin';

// Icons are ids; an unknown id draws nothing, so register yours (16×16, currentColor).
registerIcon('acme-journal', '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2"><path d="M4 2.5h8v11H4zM6 5.5h4M6 8h4M6 10.5h2"/></svg>');

const notes: Array<{ symbol: string; price: number }> = [];
let refresh = () => {};

registerWidgetAction({
    id: 'acme.note-price',                 // namespace ids: 'vendor.feature'
    target: 'context:body',
    label: msg('acme.note-price', 'Note this price'),
    icon: 'acme-journal',
    order: -100,                           // lead the menu (built-in rows sit at -30…1000)
    when: (ctx) => ctx.pointer?.paneKind === 'price' && ctx.pointer.price !== null,
    run: (ctx) => {
        notes.push({ symbol: ctx.symbol, price: ctx.pointer!.price! });
        refresh();
        ctx.togglePanel('acme.journal', true);
    },
});

// The panel gets its own toggle button in the topbar's panel group: no extra action needed.
registerSidePanel({
    id: 'acme.journal',
    title: msg('acme.journal', 'Journal'),
    icon: 'acme-journal',
    mount: (ctx, body) => {
        const list = document.createElement('ul');
        body.append(list);
        const render = () => list.replaceChildren(...notes.filter((n) => n.symbol === ctx.symbol).map((n) => Object.assign(document.createElement('li'), { textContent: String(n.price) })));
        refresh = render;
        let offMarket = () => {};
        return {
            // Runs on mount, after a rebuild and on an active-cell change, NOT on a symbol switch:
            // a switch keeps the chart, so follow it through the chart's event.
            onChart: (chart) => {
                offMarket();
                offMarket = chart.on('market:changed', render);
                render();
            },
            destroy: () => {
                offMarket();
                list.remove();
            },
        };
    },
});
```

## Rules

1. **Register at import time, before charts are built.** A chart built later picks the
   contributions up; after a late registration or an unregistration, call the shell's
   `refreshActions()`.
2. **Read everything from the context you are handed, at the moment you need it.** `ctx.chart`,
   `ctx.symbol` and `ctx.timeframe` are live getters: never keep the chart in a variable of your
   own, since a rebuild or a grid's active cell change replaces it. A symbol or timeframe switch
   keeps the chart: follow it with `chart.on('market:changed', …)`.
3. **Mount kit components on `ctx.host`.** Pass `host: ctx.host` to dialogs, menus and tooltips
   (a select takes it as `list: { host }`); without it they mount outside the chart, unthemed.
4. **Return a disposer** from every `mount`, and keep the disposers `register…` functions return
   if your plugin can be turned off (`registerIcon` has none; an icon stays registered).
5. **Menu rows take the menu's look.** The body menu shows icons; the axis menus are lists of
   checkmarked settings, so a row added there shows without its `icon`.
6. **Use the public API only.** If a feature seems to need Vela internals, look for the seam in
   `docs/contributing/plugin-sdk.md`; layers get everything they draw from `render(args)`.
7. **Text the user reads** goes through `msg('acme.area.key', 'English text')`, both arguments
   string literals, so the shell's language applies. Descriptor labels take the `msg` as is;
   text you render yourself goes through `ctx.i18n.t(message)`, and numbers and dates through
   `ctx.i18n.format`. Register translations with `registerLocale`.

## Check your work

1. Typecheck: descriptors are typed.
2. Build a chart after the registrations and exercise each contribution in the browser: the
   button or row appears (it carries `data-action-id` with your id), the panel opens from its
   button, and the overlay follows a symbol switch.
3. Destroy the chart and confirm your `destroy` and disposers ran (no leftover elements or
   timers).

## Further reading

- `node_modules/@luxalgo/vela/docs/contributing/plugin-sdk.md`: every hook with its full
  descriptor, the right-click menu ranks, layout regions, the sidebar and keyboard bindings.
- `node_modules/@luxalgo/vela/docs/user/workspace.md`: composing the topbar and the sidebar
  from the host.
- The `using-vela-ui-components` skill (shipped with `@luxalgo/vela-ui`) for the components a
  panel or overlay is built from.
