---
name: using-vela-ui-components
description: Builds interface pieces with @luxalgo/vela-ui, the component kit behind Vela charts - buttons, tabs, toggle groups, badges, dialogs, drawers, dropdown and context menus, tooltips, hover cards, popovers, toasts, collapsible sections, cards, list rows, form controls (checkbox, switch, slider, input, select, number input, date and color pickers) and data components (data table, sort buttons, month grid, figure, sparkline, bar, line and scatter charts, treemap). Use when adding or wiring these components on a page or next to a Vela chart, when a menu, dialog or tooltip from the kit renders unstyled or in the wrong place, or when the user wants UI that matches their Vela chart, even if they do not name the kit.
license: Apache-2.0
title: using-vela-ui-components
canonical_url: https://skilld.dev/gh/luxalgo/vela/using-vela-ui-components
last_updated: 2026-11-12T02:47:19.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/using-vela-ui-components`. 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/using-vela-ui-components`, 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/using-vela-ui-components) 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/using-vela-ui-components`. 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/using-vela-ui-components --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/using-vela-ui-components --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.

# Using vela-ui components

## Make a kit host first

Components take their theme and base styles from the nearest kit host, and floating parts
(menus, popovers, select lists, tooltips, dialogs) mount into it. On a page of your own:

```ts
import { createTheme, ensureUIHost } from '@luxalgo/vela-ui/theme';

const app = document.getElementById('app')!;
ensureUIHost(app, createTheme()); // dark by default; the theming-vela-ui skill covers the rest
```

Next to a Vela chart, the chart's root already is a kit host: mount inside it, or pass a
plugin's `ctx.host` as `host`. Use `ensureUIHost`, not `applyTheme`, to set a host up:
`applyTheme` only themes an element, so a menu opened from it mounts unthemed in `<body>`.

## One shape for every component

`create<Name>(props)` from `@luxalgo/vela-ui/<name>` returns a handle with `el` and
`destroy()`. Append `el` where it belongs.

```ts
import { createButton } from '@luxalgo/vela-ui/button';

const save = createButton({ text: 'Save', variant: 'default', size: 'sm', onClick: () => submit() });
app.append(save.el);
```

To find a component, its props, parts and an example, search
`node_modules/@luxalgo/vela-ui/dist/manifest.json` for `"name": "<name>"`, or run
`npx @luxalgo/vela-ui list`. Pick by need:

| Need | Component |
| --- | --- |
| An action | `button` (variants `default`, `outline`, `secondary`, `ghost`, `destructive`, `link`, `up`, `down`, `favorite`; `keys` for key caps) |
| Switch between views | `tabs` (a `description` puts a second line under a label); a few exclusive options on one track: `toggle-group` |
| A status or a count | `badge`, `figure`, `kbd` |
| A list of actions from a button or a right-click | `dropdown-menu`, `context-menu` |
| A label or a card on hover | `tooltip`, `hover-card` |
| A modal or a sheet | `dialog`, `drawer` |
| Floating content of your own | `popover` |
| A notice that leaves on its own (saved, failed, an alert fired) | `toast`: raise it with `toast()` / `toast.success(…)` from anywhere, shown by one `createToaster()` |
| A section that folds | `collapsible` |
| A panel or tile of figures, a chart with its title | `card` (`inset` for tiles inside a card; `onSelect` makes it clickable) |
| Rows of a list (a watchlist, alerts, results) | `item`, stacked by `createItemGroup` |
| A form | `input`, `input-group`, `text-area`, `number-input`, `select`, `checkbox`, `switch`, `slider`, `date-picker`, `color-picker` |
| Data | `data-table`, `sort-button` (sorts a list that is not a table), `month-grid` (a figure per day), `sparkline`, `line-chart`, `bar-chart`, `scatter-chart`, `donut`, `treemap` (weighted tiles tinted by a value, in groups that can zoom), `empty` |

## Rules that prevent the common bugs

1. **Pass `host` to a floating component built before its trigger is in the page** (a select
   takes it as `list: { host }`). Without it, the component looks for a host from the trigger,
   finds none, and mounts in `<body>`, unthemed. When unsure whether the trigger is in the page
   yet (inside a panel's `mount`, say), pass it.
2. **Start a value with `defaultValue`, `defaultChecked`, `defaultOpen` or `defaultPressed`,
   listen with the matching `on…Change`, and change it from code with `setValue`,
   `setChecked`, `setOpen` or `setPressed`.** The setters never call the listeners, so a host
   can refresh a control without loops. A select's options are fixed: build a new one to
   change them. A slider also reports `onValueCommit` once a drag ends: run costly work there.
3. **Every floating part takes the same placement props:** `side`, `align`, `sideOffset`,
   `alignOffset`, `avoidCollisions`, `collisionPadding`, `collisionBoundary`.
4. **Release what you discard.** Controls that run a state machine keep page-wide listeners
   until released: call `disposeWithin(root)` (`@luxalgo/vela-ui/dispose`) before dropping a
   subtree, or `destroy()` on the handles. A destroyed dialog, drawer or popover releases its
   content.
5. **Menus take rows as data:** `items: [{ id, label, icon?, hint?, checked?, toggle?, disabled?,
   title?, separatorBefore?, submenu? }]` and `onSelect(id)`; `title` is the row's tooltip (why
   a disabled row is unavailable). A select's options take `disabled` and `title` the same way.
   `checkmarks: true` shows checked rows with a leading check; `iconBadges: true` puts icons in
   tiles.
6. **Icons are ids from the registry** (`icon: 'kebab'`). Add your own with
   `registerIcon(id, svg)` from `@luxalgo/vela-ui/icons`, drawn with `currentColor`.
7. **Restyle through the theme or the parts' `data-slot` attributes, never class names.**
   Class names are layout hooks, not the styling contract. Your own elements beside the kit
   read the same tokens as CSS variables: `color: var(--vela-fg-muted)`,
   `background: var(--vela-surface-elev)` (names in `docs/theming.md`).
8. **An inline or authored `display` defeats the `hidden` attribute.** Toggle visibility of
   your own elements one way only: `hidden`, or `style.display`, not both.
9. **Two components called Switch.** `@luxalgo/vela-ui/switch` is the sliding switch. In
   `@luxalgo/vela/ui` 0.10, `Switch` is the deprecated name of `Checkbox`.

## Example: an order form

```ts
import { createButton } from '@luxalgo/vela-ui/button';
import { createDropdownMenu } from '@luxalgo/vela-ui/dropdown-menu';
import { createInput } from '@luxalgo/vela-ui/input';
import { createSelect } from '@luxalgo/vela-ui/select';
import { createToggleGroup } from '@luxalgo/vela-ui/toggle-group';
import { createTooltip } from '@luxalgo/vela-ui/tooltip';

const side = createToggleGroup({
    items: [{ value: 'buy', label: 'Buy', tone: 'up' }, { value: 'sell', label: 'Sell', tone: 'down' }],
    defaultValue: 'buy',
    fill: true,
    onValueChange: (value) => (order.side = value),
});
const type = createSelect({
    options: [{ value: 'market', label: 'Market' }, { value: 'limit', label: 'Limit' }],
    defaultValue: 'limit',
    fill: true,
    onValueChange: (value) => (order.type = value),
});
const size = createInput({ placeholder: 'Size', onChange: (text) => (order.size = Number(text)) });
const submit = createButton({ text: 'Place order', variant: 'default', onClick: () => place(order) });
const more = createButton({ icon: 'kebab', size: 'icon-sm', variant: 'ghost', label: 'More' });
createDropdownMenu({
    trigger: more.el,
    host: app,
    items: [{ id: 'reset', label: 'Reset form' }, { id: 'help', label: 'Order types…', separatorBefore: true }],
    onSelect: (id) => (id === 'reset' ? reset() : openHelp()),
});
createTooltip({ trigger: submit.el, content: 'Sends the order to the paper account' });

app.append(side.el, type.el, size.el, submit.el, more.el);
```

## Check your work

1. Typecheck: props are typed, so a wrong prop or variant fails there.
2. In the browser, open each floating part and confirm it sits inside the themed host:
   `el.closest('[data-vela-theme]')` is not null and its background is not transparent.
3. `npx @luxalgo/vela-ui check` finds a second installed copy of the kit, which would load
   every component twice.

## Further reading

- `node_modules/@luxalgo/vela-ui/dist/manifest.json`: every component's import, props, parts,
  settings, variants and an example.
- `node_modules/@luxalgo/vela-ui/docs/what-to-change.md`: which file or setting a change
  belongs in.
- The `theming-vela-ui` skill restyles components; `writing-vela-ui-components` builds new
  ones.
