Index of every page on this site: llms.txt
All skills
luxalgo avatar

/using-vela-ui-components

@3d2179b
by luxalgoluxalgo/vela1.4k stars
285
Run it yourself

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.

Use this Skill: https://skilld.dev/gh/luxalgo/vela/using-vela-ui-components

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈185 tokens for metadata: the name and description. ≈1.9k when used: this file.

Description uses 9.3% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈742 characters, or 9.3%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

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:

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.

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

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.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts13d3 checks · Risk SAFE
  • Gen Agent Trust Hub13d

    The skill provides comprehensive instructions and examples for using the @luxalgo/vela-ui component library to build user interfaces. It includes methods for theming, component creation, and utility commands for library management. All external resources and commands are associated with the author's official packages.

  • Socket13d

    No alerts

  • Snyk13d

    Risk: LOW · No issues

Signed by skilld at 3d2179b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 2 weeks ago

README badge

README badge for luxalgo/vela/using-vela-ui-components