Skip to content
Component installs need the registry setup
VegaStack Design

Option List Editor

Edits a choice field's options as rows — a hue, a name, remove, and add — holding no state of its own.

Status
stable
Since
0.26.0
Accessibility pattern
every control is labelled by its option; Enter commits

Last updated

Saved with 3 options.

Install

Configure registry credentials first using the Quickstart. Before copying this item or any transitive registry dependency, verify the signed manifest and save the exact bytes for Option List Editor before installation. Retain the digest printed by this command.

pnpm exec vegastack-design verify option-list-editor

Install with the pinned shadcn CLI. Bare shadcn does not verify VegaStack signature or integrity.

pnpm dlx shadcn@4.21.0 add @vegastack/option-list-editor

Run the exact offline --post-write command printed by the preflight, using its saved item path and independently retained --expected-integrity digest. Use the saved preflight for every transitive registry dependency too; stop on any mismatch before using the components.

The same command installs the registry items it composes: @vegastack/button, @vegastack/chip, @vegastack/color-picker, @vegastack/dropdown-menu-form, @vegastack/input.

Usage

import { OptionListEditor } from "@/components/ui/option-list-editor";

<OptionListEditor options={options} onChange={setOptions} onCommit={save} />;

The options are the host's: the editor draws them and reports edits. onChange follows every keystroke, so the host can show the list as it is typed. onCommit says an edit is done — a name left or confirmed with Enter, a hue picked, an option removed — which is when a host saves. An added option is not committed until it is named.

Inside a menu, pass inMenu so typing in a name stays the field's own.

Scope

  • No validation: duplicate or empty names are the host's to refuse.
  • No reordering: an option's place in the list is its order, and the host decides how to move it.

Examples

Edit and save

Saved with 3 options.

API Reference

PropTypeDefaultDescription
onChange*(options: OptionListEditorOption[]) => void—The list after every edit, keystrokes included.
onCommit*(options: OptionListEditorOption[]) => void—The list when an edit is done: a name left (blur) or confirmed with Enter, a hue picked, an option removed. An added option is not committed until it is named.
options*readonly OptionListEditorOption[]—The options, in order.
classNamestring—Extra classes for the root.
createId(() => string)crypto.randomUUIDMake an id for an added option.
inMenubooleanfalseThe editor sits inside a menu: typing in a name stays the field's own (the menu's arrow-key and type-ahead handling does not see it).
labelsPartial<OptionListEditorLabels>EnglishThe words shown, in part or whole.
maxLengthnumber200The most characters a name holds.

Data attributes and CSS variables on OptionListEditor

AttributeValues
data-slot"option-list-editor" | "option-list-editor-row"

Option

PropTypeDefaultDescription
id*string—Stable id — what a value stores.
label*string—Its name.
hueChipHueundefined — neutralOne of the ten tag hues (HUE_COLORS in color-picker).

Accessibility

  • Each name field, hue picker and remove button carries a label that names its option; the words come from labels and can be translated.
KeyAction
EnterIn a name: commit it (never submits a form)
TabMove between name, hue and remove
ContractStates tested
Behaviourdefault, empty, focused
Accessibilitylabeled, browser-accessibility-test
Visualdefault, hover

Do / Don't

Do
Save on onCommit and show the list from onChange.
Don't
Save on every onChange; a half-typed name is not an option yet.

On this page