GhostSelect specification
Status: Approved. This specification covers published single-select behavior and the multiple-selection contract approved for implementation in 0.2.0.
Important
Multiple selection is approved for implementation. The multiple-selection proposal defines the contract for #421. The resolved decisions record the earlier design review and subsequent amendments. Published versions currently support single selection. Follow #421 for multiple-selection availability.
Amendment (approved 2026-12-03): a
sizeprop on the themedGhostSelectTriggeris recorded in the Control size amendment. The maintainer @zprue743 approved the recommended contract decision (Q1–Q4) on 2026-12-03.
Amendment (approved 2026-12-04, no target release yet): a narrower scalar
update:modelValuetype for a select with a stringdefaultValueis specified in the Narrowed v-model typing amendment.
Purpose and user problems
GhostSelect is an accessible single-value select built from the WAI-ARIA APG Select-Only Combobox pattern. It targets DataTable surfaces (page-size choices, categorical filters, filter operators) and ordinary form fields composed with GhostField.
Sighted users get a compact trigger showing the current choice and a positioned list of options. Keyboard and assistive-technology users get combobox + listbox semantics, arrow-key roving among options, printable-character typeahead, and labeled options inside GhostField. The control participates in native HTML forms via a visually hidden submit input and useNativeFormReset, consistent with GhostSwitch and GhostNumberInput.
Non-goals
- Tag chips, toggle-all, or range selection. Multiple selection itself is the Multiple selection proposal; until it is merged and implemented,
GhostSelectselects one value. - Combobox with free text entry, filtering, or async search. Use
GhostInputor a future searchable combobox. GhostDropdownMenuaction-menu semantics (menu/menuitem).- Option virtualization or async option loading.
- Replacing native
<select>globally on mobile. Native OS pickers are documented as a consumer progressive-enhancement path (see Environment). - Changing overlay primitive public APIs or inventing a new styling-hooks contract (GHO-38).
Public API
Parts and exports
Headless @ghostvue/vue:
GhostSelect— root provider, value model, form submit inputGhostSelectTrigger—role="combobox"anchorGhostSelectValue— selected label / placeholder slotGhostSelectContent— portaled listbox surfaceGhostSelectOption—role="option"itemGhostSelectGroup— optionalrole="group"wrapperGhostSelectLabel— group label (idforaria-labelledby)useGhostSelect— state, registry, and form helpers- Types for props, exposed refs, context, and composable options
Themed @ghostvue/themes:
- The same part names with default list surface, trigger, and option styles
Props and configuration
GhostSelect (root)
| Prop | Type | Default | Contract |
|---|---|---|---|
modelValue | string | undefined | undefined | Controlled selected value. undefined is uncontrolled. |
defaultValue | string | undefined | undefined | Initial value when uncontrolled; omitted means no selection. Form reset restores the current defaultValue. |
name | string | undefined | Visually hidden input name for native submit. When omitted, the control does not submit. |
disabled | boolean | false | Disables trigger and options; omits value from submit. |
required | boolean | false | Native required and constraint validation on the submit input when name is set (not type=hidden). |
invalid | boolean | false | Sets aria-invalid on the trigger for Field integration. |
open | boolean | undefined | undefined | Controlled listbox open state. Omit for uncontrolled. |
defaultOpen | boolean | false | Initial open state when open is omitted. |
placeholder | string | undefined | Placeholder text when nothing is selected (also exposed to assistive tech via trigger aria-label composition when no selection). |
GhostFieldControl slot props (id, disabled, required, aria-describedby, aria-invalid) spread onto GhostSelectTrigger (the single tab stop).
GhostSelectTrigger
| Prop | Type | Default | Contract |
|---|---|---|---|
as | string | Component | 'button' | Focusable combobox host. Native button uses type="button". |
disabled | boolean | false | Disables open/close and selection. Combines with root disabled. |
GhostSelectValue
| Prop | Type | Default | Contract |
|---|---|---|---|
| — | — | — | With a selection, renders the default slot; its fallback content is the registered textValue of the selected option, else the raw value. With no selection, renders the named placeholder slot; its fallback content is root placeholder. |
GhostSelectContent
| Prop | Type | Default | Contract |
|---|---|---|---|
as | string | Component | 'div' | Listbox host. |
placement | Placement | 'bottom' | Passed to useFloating. |
offset | same as Popover | undefined | Floating offset. |
flip / shift / strategy | same as Popover | defaults match Popover | Collision handling. |
portal | boolean | true | GhostPortal when open. |
portalTo | GhostPortalTarget | 'body' | Teleport target. |
GhostSelectOption
| Prop | Type | Default | Contract |
|---|---|---|---|
value | string | — | Stable option value; unique within the root. |
disabled | boolean | false | Skipped by pointer, keyboard, and typeahead. |
textValue | string | — | Typeahead string; defaults to trimmed text content when omitted. |
GhostSelectGroup / GhostSelectLabel
GhostSelectGroup renders role="group" with aria-labelledby referencing the nearest preceding GhostSelectLabel id in the same group subtree. GhostSelectLabel renders a non-interactive label element with useGhostId.
v-model contracts
| Role | Prop | Emit | Uncontrolled initial |
|---|---|---|---|
| Selected | modelValue | update:modelValue | defaultValue or none |
| Open | open | update:open | defaultOpen |
Both use useControllableState. Switching controlled ↔ uncontrolled after setup is unsupported (GHOST001).
Unregistering an option (conditional rendering, consumer filtering, reordering, or remounting) only removes it from the keyboard and typeahead registry. It never changes the selection: an uncontrolled value stays selected, keeps submitting through the form mirror, and GhostSelectValue keeps showing the last registered label for it. No update:modelValue is emitted. The selection changes only through user selection, native form reset, or the parent's controlled modelValue. This intentionally differs from GhostRadioGroup, whose items are the visible control rather than a filtered suggestion list.
Events, slots, and exposed methods
GhostSelectdefault slot holds trigger, value, content, and options.GhostSelectValuedefault slot renders only when a value is selected and replaces the selected label. The namedplaceholderslot renders only when nothing is selected and replaces rootplaceholder.- Exposed template refs (each part):
{ element: HTMLElement \| null, focus(), blur() }. GhostSelectexposed:elementon hidden input when present, else trigger;focus()focuses the trigger. In multiple modeelementis the current first form mirror (see Native forms).
State model
| Surface | Attribute / state |
|---|---|
| Trigger | data-part="trigger", data-state="open" | "closed" |
| Content | data-part="content", data-state="open" | "closed", data-placement while open, hidden while closed |
| Option | data-part="option", data-state="checked" | "disabled" |
| Root (Field) | data-state="invalid" | "disabled" when applicable |
Content and its listbox stay mounted while closed so options keep registering their labels, so the value text resolves without opening once options register on the client. Closed content renders inline (portal disabled) with hidden and data-state="closed"; the listbox inside it carries aria-hidden="true" and inert and has no tabindex. Floating positioning, dismiss listeners, and the focus scope run only while open, so closed content adds no layers.
Consumer data
Single-value mode takes no consumer collections. Options are compound GhostSelectOption children identified by a stable string value, and the model is one string the component replaces, never mutates.
The proposed multiple mode adds one consumer-owned collection: the string[] model. Collection ownership defines who owns that array, how it is copied, and how duplicates and empty values are read. Options still are not data-driven: there are no item accessors, object values, or key callbacks.
Accessibility contract
Semantics
GhostSelectTrigger:role="combobox",aria-haspopup="listbox",aria-expanded,aria-controls→ listbox id, optionalaria-invalid,aria-requiredwhen rootrequired.GhostSelectContent:role="listbox"andaria-labelledby→ trigger id unless overridden. While open the listbox container hastabindex="-1". While closed it has notabindexand carriesaria-hidden="true"andinert(see State model).GhostSelectOption:role="option",aria-selected, rovingtabindexviauseRovingFocus(orientation: vertical).- Groups:
role="group"+aria-labelledby.
Keyboard
| Key | Where | Behavior |
|---|---|---|
Enter / Space / ArrowDown / ArrowUp | Trigger (closed) | Opens listbox; focus moves to selected enabled option or first/last enabled option for Up/Down. |
Escape | Content | Closes listbox; focus returns to trigger. |
Tab | Content | Closes listbox; default tab navigation. |
Arrow keys / Home / End | Content | useRovingFocus among enabled options. |
| Printable keys | Content | Typeahead: accumulate within ~500ms, match textValue prefix, cycle matches; focus moves to match. |
Enter / Space | Focused option | Selects option, closes listbox, focuses trigger. |
Keys that belong to an active IME composition (isComposing, or the legacy keyCode 229 that WebKit reports for an IME-processed key after compositionend) are ignored by the open listbox: they do not run typeahead, move focus, select, or close.
Native button trigger: Space/Enter on the closed trigger opens without duplicate activation from native button semantics (same guard pattern as GhostPopoverTrigger).
Focus
- One tab stop on the trigger while closed.
- On open: focus first selected enabled option, else first enabled option; listbox receives
useRovingFocuswith vertical orientation. - Order: "first", "last", typeahead matching, and roving all follow the rendered DOM order of the mounted options, not the order they registered in. Keyed reordering, inserting options before existing ones, and filtering then restoring a list therefore never change keyboard order relative to what is displayed. Unmounted options are not navigable.
- On close: restore focus to trigger unless an outside focusable was clicked (
useDismissableLayer+useFocusScopetrapped: false, matching Popover). visibility: hiddenon content untiluseFloating().isPositionedis true.
Rendering and customization
Stable hooks: data-part, data-state, data-placement on content, class ghost-select-content on themed content. Options carry data-part="option". Themed CSS uses existing --ghost-* tokens only. Content merges consumer class (string, array, or object) and style with ghost-select-content and its floating position styles, portaled or inline.
Themed GhostSelectTrigger follows the form control width rule: content width by default, stretched by a GhostField or grid cell, and full width with its block prop (data-block).
Environment behavior
SSR and hydration
useGhostIdfor trigger, listbox, and option ids.- Closed select: SSR outputs the trigger, the closed content rendered inline (
hidden,data-state="closed") with its listbox (aria-hidden="true",inert) and options, and the submit input whennameis set (overlay-ssr.test.tsasserts the closedrole="listbox"). - Trigger text in SSR:
GhostSelectOptionregisters its label only in client lifecycle callbacks, andGhostSelectValueserializes before the option subtree, so the server-rendered trigger shows the raw value. A default-closed select with valueaand option labelApplerendersaon the server. After hydration the mounted options register and the trigger text becomesApplewithout an emit or a model change. Labels resolve without opening once options register on the client. defaultOpen: truemay render listbox through deferredGhostPortalwithout touchingwindow/documentin setup; browser listeners attach inonMounted(overlay-ssr.test.tspattern).
Portal, positioning, dismissal
Reuses GhostPortal, useFloating, useDismissableLayer, and useFocusScope exactly as GhostPopoverContent does. Content defaults: placement: bottom, flip: true, shift: true, portal: true, portalTo: body.
Native fallback and mobile
Decision (v1): No automatic responsive swap to native <select>. Custom listbox is the sole headless implementation so semantics and styling stay consistent. Consumers who need OS pickers on specific breakpoints may render a native <select> beside or instead of GhostSelect, or hide the custom control with CSS and show native — outside this package.
Mobile / touch: Opening uses the same pointer path as click (useDismissableLayer capture pointerdown). Themed options use minimum block size from --ghost-control-min-height (or space tokens) for touch targets. Virtual keyboard does not interact with the listbox (no text field).
Performance
Floating observers and dismiss listeners run only while the listbox is open; content stays mounted while closed so option labels remain registered.
Option registration, unregistration, and disabled / textValue updates do constant work each (one insertion-ordered record map plus the label cache), so mounting, filtering, restoring, or reordering n options costs O(n) bookkeeping, and each option's own state re-evaluates only when that option changes. Registry state stays synchronous after every call. Measure with pnpm bench:registry (tests/bench/select-combobox-registry.bench.ts, not part of pnpm verify).
Composition
useControllableState— value and openuseGhostId— idsuseNativeFormReset+ visually hiddeninput[type="text"]— submit,required, and reset (aria-hiddenso axe ignores the mirror; the combobox trigger is the accessible control)useFloating,GhostPortal,useDismissableLayer,useFocusScope— overlayuseRovingFocus— option keyboard navigation- Local typeahead helper in
useGhostSelect(no new package dependency)
Test plan
- Vue unit tests: v-model, uncontrolled/defaultValue, disabled options, controlled emit ignore, open/close, typeahead, roving keys, required submit input constraint validation, form reset, Field aria wiring, value survives close, defaultValue label while closed, SSR hydration, value + label + FormData survive option unmount/reorder/remount without emits, first/last open focus and typeahead in DOM order after keyed reorder, insertion, filter + restore; IME-owned keys (
isComposing,keyCode229) skip typeahead, roving, selection, and Escape, and typeahead resumes afterwards - SSR:
overlay-ssr.test.tsclosed/open;expectSsrHydrationintegration; a distinct trigger-text assertion on the trigger element itself, not anywhere in the HTML: with a default-closed valueaand option labelApple, the server string shows the raw valuea, and after hydrating that markup and awaiting option registration it showsApple. Hydration and registration emit noupdate:modelValue. - E2E + axe: open/select/close keyboard paths, form submit, docs example, real focus / typeahead / selection in rendered order after list changes, WebKit-style
keyCode229 keys ignored in the listbox (tests/e2e/ime-composition.spec.ts) - Manual: Manual IME validation (automation cannot drive a real input method editor): with a Japanese, Chinese, or Korean IME on macOS Safari, macOS Chrome, Windows Chrome/Edge, and Firefox, compose text, move through candidates with the arrow keys, confirm with
Enter, and cancel withEscape; the widget state must not change until the composition is committed, and the first keys after commit must behave normally. - Visual:
examples/select/themedbaselines viapnpm test:visual:docker - Type: consumer compile fixture
- Multiple (proposed): the additional cases, including single-select type and keyboard regressions, are listed in Multiple selection test plan.
Documentation plan
docs/components/select.md, examples basic, field, form, themed, playground section, sidebar + roadmap status, manifests via pnpm manifests:write. The proposed multiple mode adds the pages and examples in Multiple selection documentation plan.
Compatibility and release impact
Additive minor Changesets for @ghostvue/vue and @ghostvue/themes.
The proposed multiple mode is additive: multiple defaults to false, and the single-value props, emits, keyboard map, and FormData shape stay as published. Multiple selection compatibility lists the exported types it touches.
Multiple selection proposal
Note
Proposal for #415. Nothing in this section is implemented. Each maintainer decision is tagged with its ID (S1–S7, signed off as proposed; see Resolved decisions). Where a rule is not tagged, this spec proposes it as the natural extension of the published single-value contract or of GhostCombobox multiple.
Purpose and non-goals
Filters, label pickers, and notification settings often need several values from a list too long to keep on screen. GhostCheckboxGroup (#463) covers choices that stay visible. GhostCombobox multiple covers lists users search by typing. A multiple GhostSelect covers the case in between: a compact trigger, a popup listbox without a text field, and one string[] model that submits with the form like a native <select multiple>.
Out of scope for this proposal:
- Removable tag chips inside the trigger, a "select all" option, or option limits (
min/max). Consumers build these from the model and theGhostSelectValueslot. Rules such as "choose at most three" belong toGhostForm(#414) or the consumer. - APG range and select-all keys (
Shift+Arrow,Shift+Space,Ctrl+Shift+Home/End,Ctrl+A) (S3). - Object values, item accessors, or data-driven options. Option values stay strings.
- Changing
GhostComboboxmultiplebehavior. Differences between the two are noted where they matter.
Scalar and multiple examples
The published scalar select and the proposed multiple select use the same parts. Only the root changes.
Scalar (published, unchanged)
<script setup lang="ts">
import { ref } from 'vue'
// Emitted as `string | undefined`.
const region = ref<string | undefined>()
</script>
<template>
<GhostSelect v-model="region" name="region" placeholder="Choose a region">
<GhostSelectTrigger aria-label="Region">
<GhostSelectValue />
</GhostSelectTrigger>
<GhostSelectContent>
<GhostSelectOption value="us-east">US East</GhostSelectOption>
<GhostSelectOption value="eu-west">EU West</GhostSelectOption>
</GhostSelectContent>
</GhostSelect>
</template>Multiple (proposed)
<script setup lang="ts">
import { ref } from 'vue'
// Emitted as a new `string[]` on every change; never `undefined`.
const labels = ref<string[]>(['bug'])
</script>
<template>
<GhostSelect v-model="labels" multiple name="labels" placeholder="Add labels">
<GhostSelectTrigger aria-label="Labels">
<GhostSelectValue />
</GhostSelectTrigger>
<GhostSelectContent>
<GhostSelectOption value="bug">Bug</GhostSelectOption>
<GhostSelectOption value="docs">Docs</GhostSelectOption>
<GhostSelectOption value="triage">Needs triage</GhostSelectOption>
</GhostSelectContent>
</GhostSelect>
</template>Uncontrolled with defaultValue
<!-- Scalar: Multiple = false, defaultValue is `string | undefined` -->
<GhostSelect name="region" default-value="us-east">…</GhostSelect>
<!-- Multiple: Multiple = true, defaultValue is `readonly string[]` -->
<GhostSelect
name="labels"
multiple
:default-value="['bug', 'docs']"
>…</GhostSelect>Type inference
GhostSelect becomes a generic component, <script setup lang="ts" generic="Multiple extends boolean = false"> (S1, S6), following GhostDataTable's generic="TData". The bare multiple attribute passes the literal true, so Multiple is inferred from the template. Proposed exported helpers:
/** Value accepted by `modelValue` / `defaultValue` for a root. */
export type GhostSelectValueInput<Multiple extends boolean = false> =
Multiple extends true ? readonly string[] : string
/** Value emitted by `update:modelValue`. */
export type GhostSelectModelValue<Multiple extends boolean = false> =
Multiple extends true ? string[] : string | undefined| Template | Multiple | modelValue / defaultValue accepted | update:modelValue payload |
|---|---|---|---|
<GhostSelect v-model="region"> | false | string | undefined | string | undefined (unchanged) |
<GhostSelect default-value="us-east"> | false | string | undefined | string | undefined (unchanged) |
<GhostSelect multiple v-model="labels"> | true | readonly string[] | undefined | string[] |
<GhostSelect multiple :default-value="['bug']"> | true | readonly string[] | undefined | string[] |
<GhostSelect :multiple="isMulti"> (isMulti: boolean) | boolean | string | readonly string[] | undefined | string | string[] | undefined |
Rejected at compile time (type regression fixtures):
<GhostSelect v-model="labels">withlabels: Ref<string[]>and nomultiple: the array is not astring.<GhostSelect :default-value="['bug']">withoutmultiple.<GhostSelect multiple default-value="bug">and<GhostSelect multiple v-model="region">withregion: Ref<string | undefined>.<GhostSelect multiple :default-value="[1, 2]">: members are strings.
A wide boolean flag compiles to the union and is documented as discouraged; the value shape is still fixed at setup (S7). Inference from the bare multiple attribute was verified against the repo's vue-tsc (3.3.14): a prototype root declared with generic="Multiple extends boolean = false" and these prop and emit types infers Multiple = true from multiple, every accepted row above compiles, and every rejected form fails with TS2322. S1 is therefore locked. If a later toolchain change breaks this inference, implementation stops and the regression goes back to the maintainer for new sign-off. It does not switch to a separate root or to an untyped string | string[] model like GhostCombobox's.
Public API additions
GhostSelect (root)
| Prop | Type | Default | Contract |
|---|---|---|---|
multiple | Multiple (boolean) | false | Selects the multiple model. Read once at setup (S7). |
modelValue | GhostSelectValueInput<Multiple> | undefined | undefined | Multiple: controlled readonly string[]. undefined is uncontrolled, as in single mode. [] is the controlled empty value. |
defaultValue | GhostSelectValueInput<Multiple> | undefined | undefined | Multiple: uncontrolled seed, copied at setup and again at form reset. Omitted means []. |
messages | GhostSelectMessages | undefined | Adds listSeparator?: string (default ', ') for the default multiple value text (S4). required keeps its default 'Select a value.'. |
name, form, disabled, required, invalid, open, defaultOpen, and placeholder keep their single-mode meaning; the differences are in Native forms. No part gains a prop.
GhostSelectValue slots (S4)
| Slot | Props (both modes) | Rendered when |
|---|---|---|
default | { values: readonly string[]; labels: readonly string[] } | At least one value is selected. |
placeholder | none | Nothing is selected. |
values is selectedValues: the model in model order with duplicates removed, keeping the first occurrence, so a controlled ['bug', 'bug'] gives values: ['bug'] and labels: ['Bug'], like the default value text and the form mirrors. labels[i] is the label for values[i]. Single mode passes one-element arrays, so the props are additive: an existing <GhostSelectValue> default slot that ignores props renders as before.
useGhostSelect (S6)
useGhostSelect<Multiple extends boolean = false>(options) gains multiple?: MaybeRefOrGetter<Multiple>. Calls without it keep today's selectedValue: Ref<string | undefined> type. In multiple mode useGhostSelect<true> returns selectedValue: Readonly<Ref<readonly string[]>>, so code cannot type-check an in-place push, splice, or sort of the parent's array, or an assignment to .value. Additions:
multiple: ComputedRef<boolean>on the composable result.Discriminated context (S6 revision).
GhostSelectContextis a union keyed by a plain, setup-fixedmultipleliteral (S7), not a ref, so TypeScript can narrow on it:tsinterface GhostSelectSingleContext extends GhostSelectContextBase { readonly multiple: false selectedValue: Ref<string | undefined> } interface GhostSelectMultipleContext extends GhostSelectContextBase { readonly multiple: true selectedValue: Readonly<Ref<readonly string[]>> replaceSelection: (values: readonly string[]) => void } type GhostSelectContext = GhostSelectSingleContext | GhostSelectMultipleContextGhostSelectContextBaseholds every other existing field plusselectedValues. Reads work without narrowing (ctx.selectedValue.valueisstring | readonly string[] | undefined). Writes are mode-safe: under a multiple rootselectedValue.value = 'bug'(or any assignment) fails withTS2540because the ref is readonly, and under a narrowed single rootselectedValue.value = ['bug']fails withTS2322. An unnarrowed assignment also fails, sincevalueis readonly in one branch, so a single-mode write has to narrow onctx.multiple === falsefirst.selectedValues: ComputedRef<readonly string[]>: the selection in model order with duplicates removed;[]or one value in single mode. Value text,aria-selected, and the form mirrors read this.select(value): single mode sets the value and closes (unchanged). Multiple mode toggles membership and leavesopenalone, matchingGhostCombobox'sselect.Write path. In single mode, context consumers change the selection through
select(value)or, after narrowing, by assigningselectedValue.value(unchanged). In multiple mode they useselect(value)(toggle) orreplaceSelection(values), which replaces the whole selection.replaceSelectioncopies the given array into a new, duplicate-freestring[]before it stores or emits it, so passing the received array, a frozen array, or any readonly array never aliases it and the emitted array stays receiver-owned (see Collection ownership). The component never mutates the array it reads.formInputPropsstays the single-mode object. A newformInputs: ComputedRef<GhostSelectFormInputProps[]>lists one mirror per value in multiple mode, or one unnamed reset anchor whennameis set and the selection is empty (see Native forms).
Collection ownership, empty values, and duplicates
- Ownership. In controlled mode the parent owns the array. The component reads it and never mutates it (no
push,splice, or sort). Every user change emits a new array. A frozen controlled array works. In uncontrolled mode the component copiesdefaultValueat setup and at reset, so later in-place mutation of the seed array is not observed until the next reset. - Emitted arrays are new, mutable
string[]instances owned by the receiver. The component never emits the array it received. - Context reads are readonly.
GhostSelectContext.selectedValueandselectedValuesexpose the current array asreadonly string[], which can be the parent's controlled array itself, so the context offers no typed path to mutate it in place or assign it. Writes go throughselect(value)orreplaceSelection(values), which copies (seeuseGhostSelect). - Empty value.
[]. Multiple mode never emitsundefined. A controlled parent that passesundefinedmakes the root uncontrolled, as in single mode (GHOST001 covers switching). ''as an option value is unsupported in both modes. Single mode already treats''as "no selection" forrequired, and its keyboard path ignores an option whosedata-valueis empty. Multiple mode treats a''member in a controlled model like any unknown value: it is retained and rendered as text, but no option can toggle it.- Duplicates in the model (a controlled
['bug', 'bug']) are read as one membership.selectedValues, value text, and the form mirrors use the first occurrence. The component does not emit to normalize them. The first user toggle of that value removes every occurrence, and every emitted array is duplicate-free. - Duplicate option values stay a consumer error, as in single mode (
valuemust be unique within the root).
Selection ordering (S2)
The model is kept in selection order:
- Selecting a value appends it:
['bug']thenDocsgives['bug', 'docs']. - Deselecting removes it and keeps the rest in place: toggling
Bugoff gives['docs']. - Reselecting appends again:
['docs', 'bug']. - Option reordering, insertion, filtering, and remounting never reorder the model.
defaultValue and a controlled modelValue keep the order the parent gave. Value text, GhostSelectValue slot props, and FormData all use model order. Keyboard order is unrelated: it follows rendered DOM order, as in single mode.
The alternative (S2) is rendered option order, which is what native <select multiple> submits and what Vue's v-model on a native multiple select produces.
State model
| State | Owner | Changes when |
|---|---|---|
| Selected set | modelValue (controlled) or internal copy | User toggles an option, native form reset, or the parent's controlled value. |
| Open | open (controlled) or internal | Trigger, Escape, Tab, outside pointer. Toggling never changes open. |
| Active option | DOM focus inside the listbox | Arrow keys, Home / End, typeahead, pointer, open-time focus. |
Active versus selected. The active option is the one that holds DOM focus (roving tabindex through useRovingFocus, as today; no aria-activedescendant). Selected options are the model members, shown with aria-selected="true" and data-state="checked". The two are independent: moving focus never selects, and toggling never moves focus. Styling the active option uses :focus-visible; no new styling hook is added.
Each toggle emits update:modelValue once, immediately, with the full new array. There is no "commit on close". A controlled parent that rejects a change (keeps its array) keeps its value, and aria-selected follows the parent's array.
Options that disappear or reorder
The single-value rule extends to every member:
- Unregistering an option (conditional rendering, filtering, keyed reorder, remount) never removes its value from the model, never emits, and keeps submitting it.
GhostSelectValuekeeps the last registeredtextValuefor a member whose option has unmounted. A member that never had an option (for example a controlled value from the server) renders as the raw value string, as single mode does today.- When the option mounts again it shows
aria-selected="true"without an emit. - Reordering options changes keyboard order only. Model order, value text, and FormData stay the same (S2).
- If the focused option unmounts while the listbox is open, focus moves to the next enabled option in rendered order, else the previous, else the listbox container (
tabindex="-1"), soEscapeandTabstill work (S3).
Disabled options and root
- A disabled option cannot be toggled by pointer, keyboard, or typeahead. If it is already selected it stays selected, keeps
aria-selected="true", and keeps submitting (S5). - Root
disableddisables the trigger and every option. The value text still renders. All form mirrors, including the empty reset anchor, aredisabled, so nothing submits.
Accessibility contract (multiple)
Semantics
| Element | Single mode (published) | Multiple mode (proposed) |
|---|---|---|
GhostSelectTrigger | role="combobox", aria-haspopup="listbox", aria-expanded, aria-controls | Same attributes. No aria-multiselectable on the combobox (not a supported state there). |
| Listbox | role="listbox", aria-labelledby → trigger | Adds aria-multiselectable="true" whenever the listbox renders, open or closed (hidden). |
GhostSelectOption | aria-selected="true" on the value, "false" on the rest | aria-selected="true" on every member and "false" on every other option, so screen readers announce "not selected" too. |
| Disabled option | aria-disabled="true" | Same; selected and disabled reads both states. |
The trigger's text content is its value as announced by screen readers: the value text below when something is selected, otherwise the placeholder. The accessible name still comes from the Field label or aria-label, never from the value.
Keyboard
Trigger keys are unchanged. Listbox keys in multiple mode:
| Key | Where | Single mode (published, regression-tested) | Multiple mode (proposed) |
|---|---|---|---|
Enter / Space / ArrowDown / ArrowUp | Trigger (closed) | Opens; focus to selected or first/last enabled option. | Same. Focus goes to the first selected enabled option in rendered order, else first (or last for ArrowUp) enabled option. |
Space | Focused option | Selects, closes, focuses trigger. | Toggles the option. List stays open; focus stays on the option. |
Enter | Focused option | Selects, closes, focuses trigger. | Toggles, like Space (S3). |
Arrow keys / Home / End | Listbox | Moves focus among enabled options. | Same; never changes selection. |
| Printable keys | Listbox | Typeahead moves focus. | Same; never changes selection. |
Escape | Listbox | Closes; focus to trigger. | Same. Selection made while open is kept. |
Tab / Shift+Tab | Listbox | Closes; default tab navigation. | Same. |
IME-owned keys (isComposing, keyCode 229) are ignored exactly as in single mode, including the toggle keys. Space and Enter on a toggle call preventDefault so the page does not scroll and the native button trigger is not re-activated.
Pointer, open, and close
- Clicking an enabled option toggles it, keeps the list open, and moves focus to that option so keyboard use continues from there.
- Clicking the trigger while open closes the list and keeps focus on the trigger. An outside pointer closes without restoring focus, as in single mode. Neither changes the selection.
- Controlled
openstays parent-owned; toggling never emitsupdate:open.
Assistive technology expectations
aria-multiselectable makes screen readers announce a multi-select list on entry. Toggling changes aria-selected on the focused option, which NVDA and VoiceOver announce as "selected" / "not selected", so no live region is added. On close, focus returns to the trigger and its text reads the new value list. AT verification (NVDA + Firefox, VoiceOver + Safari) follows the existing assistive-technology review before the manifest can move to stable.
Value and placeholder rendering
| Model | Default GhostSelectValue text (S4) | data-state on value part |
|---|---|---|
[] | placeholder slot, else root placeholder | none |
['bug'] | Bug | checked |
['docs', 'bug'] | Docs, Bug (model order, listSeparator) | checked |
['bug', 'gone'], gone never registered | Bug, gone (raw value fallback) | checked |
The default text is plain text, so long lists are truncated by consumer or themed CSS (the themed trigger already ends long text with an ellipsis). The scoped default slot covers summaries such as "3 labels" or chips that are not interactive. Interactive chips with remove buttons inside the trigger are out of scope because the trigger is a button.
Native forms, reset, and disabled
With name set, multiple mode renders one visually hidden input[type="text"] per distinct member, in model order, all sharing name and form. Values containing commas therefore need no encoding (the same rule as GhostCombobox multiple). When the selection is empty, exactly one mirror stays rendered without name: the reset anchor. It keeps form, disabled, and (when required) the validity attributes, so it holds the control's form association without adding a FormData entry. With name set there is therefore always at least one mirror.
<form ref="form">
<GhostSelect multiple name="labels" :default-value="['bug', 'docs']">
…options: bug, docs, triage…
</GhostSelect>
<GhostSelect name="region" default-value="us-east">…</GhostSelect>
</form>new FormData(form).getAll('labels') // ['bug', 'docs']
// User toggles "Needs triage" on, then "Bug" off.
new FormData(form).getAll('labels') // ['docs', 'triage']
// User toggles every option off.
new FormData(form).getAll('labels') // []
form.reset() // update:modelValue(['bug', 'docs']), a new array
new FormData(form).getAll('labels') // ['bug', 'docs']
// Scalar select in the same form (published behavior, unchanged):
new FormData(form).getAll('region') // ['us-east']; [''] when nothing is selectedThe root form prop associates the control with a form it is not inside:
<form id="filters" ref="filters"></form>
<!-- Elsewhere in the page, outside <form id="filters"> -->
<GhostSelect multiple name="tags" form="filters" :default-value="['bug']">
…options: bug, docs…
</GhostSelect>// User toggles "Bug" off; only the unnamed reset anchor remains.
new FormData(filters).getAll('tags') // []
filters.reset() // update:modelValue(['bug'])
new FormData(filters).getAll('tags') // ['bug']- Empty. An empty multiple select submits nothing, so
getAll(name)is[], as with native<select multiple>: the only rendered mirror is the unnamed reset anchor, and unnamed controls are not submitted. This differs fromGhostComboboxmultiple, which submits one empty mirror (['']); the combobox is not changed by this proposal. - Required. Validity is decided by membership, not order: a
requiredmultiple select is satisfied when the selection has at least one member other than'', matching single mode, which treats''as no selection.requiredgoes on one mirror: the first mirror whose value is not'', or, when there is none, the first mirror (the reset anchor when the selection is empty, or the first''member mirror for a model such as['']). Custom validity follows the collection, asuseGhostSelect.syncFormValiditydoes in single mode: when no member other than''exists, the required-bearing mirror getssetCustomValidity(messages.required)and its empty value also failsvalueMissing, so it blocks submit and focuses the trigger. Otherwise the required-bearing mirror's custom validity is cleared withsetCustomValidity(''), so a satisfied collection has nocustomError. Every other mirror also has its custom validity cleared each time validity syncs, including a mirror that stays mounted while the required-bearing role moves away from it: going from['']to['', 'bug']clears the stale message on the still-mounted''mirror. The anchor adds no FormData entry. So['bug'],['', 'bug'], and['bug', '']are all valid, and[]and['']are invalid withmessages.required. - Reset. Native form reset restores a copy of the current
defaultValue(or[]) and emitsupdate:modelValueonly when membership or order differs from the current value, matching single mode's no-op on an equal value. - Reset with an external
form.useNativeFormResetmatches aresetevent against the owner form of the element it is given, readingelement.form. Single mode passes the mirror and falls back to the trigger only when no mirror renders (GhostSelect.vue). The trigger does not carry the rootformprop, so its owner is only its ancestor<form>. Multiple mode passes the first mirror, which withnameset is always present (a member mirror or the reset anchor). Itsformattribute therefore keeps the association after the user clears every value, and an externalform.reset()restores a nonemptydefaultValue. When the anchor is replaced by a member mirror or the reverse, the listener reads the current first mirror at event time, so no reset is lost across the swap. The anchor is stilldisabledunder rootdisabled; a disabled input keeps itsformowner, so reset still applies. - Without
name. No mirror renders and the trigger is the reset target, as in single mode today: reset follows the trigger's ancestor<form>, and the rootformprop has no effect. - Exposed
element.GhostSelect's exposedelementis the same elementuseNativeFormResetuses: the current first mirror (the first member mirror in model order, or the reset anchor when the selection is empty), else the trigger whennameis not set. It is read when accessed, so it follows the first mirror as the selection changes: with['bug', 'docs']it is thebugmirror, after togglingbugoff it is thedocsmirror, and after clearing every value it is the reset anchor. It is never a later mirror and never the trigger whilenameis set. - Root
disabled. Every mirror is disabled:getAll(name)is[], the value text still renders. <fieldset disabled>ancestor. Native rules exclude the mirrors from submission and disable the nativebuttontrigger, the same as single mode.- Disabled selected option. Keeps submitting (S5).
Environment behavior (multiple)
A closed SSR render outputs the trigger, one mirror per member (or the unnamed reset anchor when empty) when name is set, so the server markup submits the same entries as the hydrated control, and, as in single mode, the hidden listbox (hidden content, aria-hidden="true", inert) with its options (see State model). Options register their labels only in client lifecycle callbacks, and GhostSelectValue serializes before the option subtree, so the server-rendered trigger text uses the raw value for each member: a default-closed ['bug'] renders bug. After hydration the mounted options register and the trigger text becomes the label Bug without an emit or a model change. The rendered listbox carries aria-multiselectable="true" and aria-selected on every option ("true" on members, "false" on the rest) in either state; an open SSR render (defaultOpen: true) shows the same listbox without hidden. Hydration must not emit in either case. Touch uses the same pointer path as click; options keep the themed minimum block size.
Performance
Membership checks read a Set derived from the model once per model change, so isSelected stays O(1) per option and a toggle costs O(n) in the number of members (one new array). The registry and its O(1) bookkeeping are unchanged. The pnpm bench:registry benchmark gains a multiple-mode case with 3000 options and 500 members.
Composition
Reuses everything single mode uses (useControllableState, useGhostId, useNativeFormReset, useFloating, GhostPortal, useDismissableLayer, useFocusScope, useRovingFocus, the typeahead helper) plus:
- The multiple-mirror pattern from
useGhostCombobox, changed so the empty mirror has nonameand is kept whether or not the select isrequired(the reset anchor). - The generic setup overload pattern from the themed
GhostDataTablewrapper for the themedGhostSelect(S6). Its runtimeupdate:modelValuevalidator must also acceptstring[].
No new package, dependency, or shared primitive.
Multiple selection test plan
- Vue unit tests (multiple): toggle on and off by click,
Space, andEnter; list stays open and focus stays on the option; selection order (append, remove in place, reselect appends); emitted arrays are new and duplicate-free; a frozen controlled array is never mutated; controlled parent rejecting a toggle keepsaria-selectedon its value; duplicates in a controlled model read as one member without an emit; passing a frozen array, or the parent's own array, to the context'sreplaceSelectionemits a new, duplicate-free array and leaves the passed array unchanged;[]vsundefined;defaultValuecopied at setup and reset; reset emits only when different; options unmounting, reordering, inserting, and remounting keep model, value text, and FormData without emits; focused option unmount moves focus (S3); disabled selected option stays selected and submits (S5); rootdisabled;requiredwith the unnamed empty mirror;requiredwith a controlled['', 'bug']and with['bug', '']is valid in both orders (requiredis on thebugmirror), and['']is invalid; a required['bug']passescheckValidity()withvalidity.customErrorfalse on every mirror, and toggling the last nonempty member off setsmessages.requiredon the anchor, while toggling one back on clears it; a required controlled['']updated to['', 'bug']passescheckValidity()withvalidity.customErrorfalse on the still-mounted''mirror; optional empty select withnamerenders exactly one unnamed reset anchor carryingform; external-form reset: with the rootformprop pointing at a form the select is not inside and a nonemptydefaultValue, clear every option, assertgetAll(name)is[]and the anchor has noname, call that form'sreset(), await the reset deferral, and assert the default is restored (one emit, new array) andgetAll(name)equals it; areseton the ancestor form of the trigger does not reset an externally associated select; exposedelement: withnameand['bug', 'docs']it is thebugmirror, after togglingbugoff it is thedocsmirror, after clearing every value it is the unnamed reset anchor, after togglingbugback on it is thebugmirror, and withoutnameit is the trigger; IME keys ignored for toggles;GhostSelectValueslot props andlistSeparator; a controlled['bug', 'bug']passes slot propsvalues: ['bug']andlabels: ['Bug']and renders the default textBugonce, without an emit. - Single-select regressions (must pass unchanged): every existing
GhostSelect.test.ts,select-combobox-*.test.ts, andghost-select*.test.tscase; plus explicit assertions that singleSpace/Enterstill select, close, and focus the trigger; the listbox has noaria-multiselectable; unselected options keeparia-selected="false"; empty single still submits[''];GhostSelectValuedefault slot without props renders unchanged; with no selection only the namedplaceholderslot renders (else rootplaceholder), and the default slot renders only after a selection; the closed listbox has notabindexand the open listbox hastabindex="-1". - Type tests: new
packages/vue/type-tests/GhostSelectConsumer.tsand.vuecovering every row of the type inference table, andpackages/vue/type-tests-negativecases for each rejected form. The single-mode cases (v-modelwithRef<string | undefined>,default-value="…",update:modelValuepayloadstring | undefined) are the regression fixture for existing consumers. Same cases against the@ghostvue/themeswrapper. Context type cases (S6 revision): after narrowing onctx.multiple, a multiple context rejectsselectedValue.value = 'bug'and any other assignment (TS2540) andselectedValue.value.push(…)(TS2339). A single context rejectsselectedValue.value = ['bug'](TS2322). An unnarrowed assignment is rejected, andctx.replaceSelectionis rejected before narrowing to multiple. Accepted: unnarrowed reads asstring | readonly string[] | undefined,select(value),replaceSelection(frozenArray)on a multiple context, andselectedValue.value = 'a'orundefinedon a narrowed single context. - SSR, closed: a default-closed multiple select with
defaultValue: ['bug']renders the hidden listbox (role="listbox"insidehiddencontent,aria-hidden="true",aria-multiselectable="true") and one mirror per member; with an empty value it renders the unnamed reset anchor instead. The trigger text is asserted on the trigger element itself, not anywhere in the HTML: in the server string it is the raw valuebug. After hydrating that markup and awaiting option registration, the trigger text is the labelBug. Hydration and registration emit nothing. - SSR, open: with
defaultOpen: true, the rendered listbox hasaria-multiselectable="true", members havearia-selected="true", and other options havearia-selected="false"; the mirrors match the closed case. Hydration emits nothing. - Browser (Playwright): in a multiple playground section, press every documented key and assert real focus (
toBeFocused()),aria-selected,aria-expanded, and that the list stays open after toggles; pointer toggles;FormData.getAll(name)after toggles, after clearing, and afterform.reset(); the same sequence for a select associated through the rootformprop with a form it is not inside (clear every option by pointer,getAll(name)is[], call that form'sreset(), the nonempty default is restored in the trigger text andgetAll(name)); axe with the list open and closed. The existingtests/e2e/select.spec.tssingle-select tests run unchanged as the keyboard regression suite. - Visual: themed multiple trigger with zero, one, and many values (long list ellipsis) via
pnpm test:visual:docker. - Manual / AT: NVDA + Firefox and VoiceOver + Safari announce the multi-select list, "selected" / "not selected" on toggle, and the value list on the trigger after close.
Multiple selection documentation plan
docs/components/select.md: a "Multiple selection" section with a themed example (examples/select/multiple-labels.vue) and a form example showingFormData.getAlland reset (examples/select/multiple-form.vue), both listed in the manifest.- Guidance on choosing between multiple
GhostSelect,GhostComboboxmultiple, andGhostCheckboxGroup. - Generated API tables via
pnpm manifests:writeandpnpm docs:api:write(multipleprop,GhostSelectValueslot props, emit payload). - Playground section with test ids for the browser tests.
Multiple selection compatibility
- Additive at runtime.
multipledefaults tofalse; single-mode props, emits, keyboard behavior, FormData, and markup do not change. - Exported types (S6).
GhostSelectbecomes generic withMultiple = falseas the default, so existing single consumers infer the same types; the type regression fixture proves it.GhostSelectMessagesgains an optional field.GhostSelectContextbecomes a union discriminated bymultiple(S6 revision). This is a type-level change for consumers who use the context directly: reads ofselectedValue.valuewiden tostring | readonly string[] | undefined, and single-mode writes must narrow onctx.multiple === falsefirst. S6 approved changing the context for0.2.0over a separate field. - Themed wrapper. Gains
multipleand the generic overload; its emit validator widens. - Changesets. Minor for
@ghostvue/vueand@ghostvue/themesin the implementation PR. This docs-only spec PR needs none.
Resolved decisions
The single-value contract has no open questions. For the multiple mode, the maintainer signed off on the proposed choice for each of S1–S7 at commit 6e84b32 (6e84b3241edb0b4a0e096537950c295c266c8b81). The repo admin zprue743 recorded the sign-off on 2026-11-28 in PR #512. This is design sign-off only. It is not merge approval or release inclusion. The table keeps each rejected alternative for the record.
| ID | Decision | Approved choice | Rejected alternative |
|---|---|---|---|
| S1 | API shape | multiple boolean on the existing GhostSelect root. The root becomes generic over Multiple extends boolean = false, so the flag selects the model type. | A separate GhostMultiSelect root that shares the parts. Simpler types, but a second root to document and theme. |
| S2 | Value order | Selection order. Selecting appends; deselecting removes in place. FormData uses the same order. Matches GhostCombobox multiple and Vue's checkbox array v-model. | Rendered option order, like native <select multiple> and Vue's vModelSelect. Order then changes when options reorder. |
| S3 | Keyboard and focus | Enter and Space both toggle the focused option and keep the list open. Shift+Arrow, Shift+Space, and Ctrl+A are not handled. If the focused option unmounts, focus moves to the next enabled option, then the previous, then the listbox. | Enter closes the list instead of toggling, or v1 adds the APG range and select-all keys. |
| S4 | Value rendering | GhostSelectValue joins option labels in model order with ', ' (messages.listSeparator overrides it). New scoped slot props { values, labels } cover custom summaries. | A count summary such as "3 selected", with a messages.selectedCount callback. |
| S5 | Disabled selected options | A selected option that is disabled stays selected and keeps submitting. disabled blocks user toggling only, as it already does in single mode and in GhostCombobox. | Exclude it from FormData, like a disabled native <option>. The model and the submitted values would then differ. |
| S6 | Exported type surface | Generic useGhostSelect<Multiple> and GhostSelect props. GhostSelectContext widens selectedValue to string | readonly string[] | undefined and adds multiple and selectedValues. The themed root gets a generic setup overload. Revised after sign-off into a union discriminated by multiple (see S6 context revision below). | Keep GhostSelectContext.selectedValue single-only and add a separate selectedValues field, at the cost of two value refs. |
| S7 | Changing multiple after mount | Unsupported. The value keeps its original shape, and development builds log a new GHOST0xx warning (code assigned at implementation). | Reactive switching that converts 'a' to ['a'] and keeps the first member on the way back, with an emit. |
Post-sign-off amendments
After the S1–S7 sign-off, the maintainer zprue743 asked for review findings to be applied in PR #512 (follow-ups linked below). They were applied at those requests. They narrow the form, SSR, and context-type contracts and do not change any signed-off decision. They are not a new approval. The order-independent required and S1/S6 entries apply Codex review findings that had no maintainer handoff; they clarify the signed-off choices and change none of them. The one exception is the S6 context revision, which changes the S6 context shape. It has its own design sign-off from the maintainer, linked in that entry.
- Closed SSR listbox (
512-closed-ssr-listbox, review comments 4728404849 and, revised, 4728514797). The State model now matchesGhostSelectContent: the closed listbox stays mounted and hidden so options register, replacing the earlierv-if="open"sentence.aria-multiselectableis required on the rendered listbox open or closed, and the closed SSR case checks the hidden listbox and the form mirrors or anchor (see Environment behavior (multiple)). - SSR trigger label (
512-ssr-trigger-label, review comment 4728578876). Options register labels only on the client, so the server-rendered trigger shows the raw value (bug) and shows the label (Bug) only after client registration. The closed SSR case asserts the trigger text separately in both phases, with no emit. - Scalar SSR trigger (
512-scalar-ssr-trigger, review comment 4728761826). The single-mode SSR and hydration guarantee now matches current behavior: the server-rendered trigger shows the raw value (a) and shows the label (Apple) only after client option registration. The single-mode SSR test asserts the trigger text separately in both phases, with no model emit. - Readonly context value (
512-readonly-context, review comment 4728761984). S6's widenedGhostSelectContext.selectedValuekeeps the array branchreadonly(string | readonly string[] | undefined), so the parent's array is never mutated through the context and emitted arrays stay receiver-owned (seeuseGhostSelect). The S6 context revision below replaces this entry's multiple-mode setter withreplaceSelection. - Order-independent required validity (Codex review comment 4728793138).
requiredis satisfied by any member other than'', and the required attributes go on the first mirror with a nonempty value, so a controlled['', 'bug']and['bug', '']validate the same way. The custommessages.requiredis set only when no such member exists and is cleared otherwise, so a satisfied collection has nocustomError(Codex review comment 4728944288). Every mirror other than the required-bearing one has its custom validity cleared, so a mirror that stays mounted when that role moves keeps no stale message (Codex review comment 4728962235); see Native forms). - S6 context revision (maintainer decision, review comment 4729125899, on Codex finding 4728944293).
zprue743chose option 2 ata24d616:GhostSelectContextis a union discriminated bymultiple. The single branch has a scalarselectedValue. The multiple branch has a readonly-arrayselectedValueandreplaceSelection, so TypeScript rejects wrong-shape writes. This is design sign-off for the S6 revision only. It does not authorize merging. The narrowing was checked withvue-tsc3.3.14 on a prototype of these types (not committed). Under a multiple root, assigning'bug'(or any value) fails withTS2540. Under a narrowed single root, assigning an array fails withTS2322. An unnarrowed assignment fails withTS2540. Reads,select,replaceSelection, and narrowed single writes compile. SeeuseGhostSelect. - Normalized value slot props (Codex review comment 4728962234).
GhostSelectValueslotvaluesare the duplicate-freeselectedValues, matching how duplicates count as one member elsewhere (seeGhostSelectValueslots). - S1 and S6 locked (Codex review comment 4728793134). The spec no longer offers the rejected separate-root or separate-field alternatives as fallbacks. Inference from the bare
multipleattribute was checked withvue-tsc3.3.14 (see Type inference); a later regression goes back for new sign-off. The approved choices are unchanged. - Closed listbox
tabindex(Codex review comment 4729149831). The Semantics bullet now requirestabindex="-1"on the listbox only while open, matchingGhostSelectContentand the State model, which says the closed listbox has none. GhostSelectValueslot contract (Codex review comment 4729149834). The publishedGhostSelectValuerow and slot bullet now match the current component: the default slot renders only with a selection and the namedplaceholderslot only without one. This corrects the earlier wording, which said the default slot was the placeholder, and agrees with the S4 slot table.- Exposed root
element(Codex review comment 4729149838). In multiple modeGhostSelect's exposedelementis the current first mirror (a member mirror or the reset anchor), the same element used for form reset, else the trigger withoutname. A unit test covers the transitions (see Native forms). - External-form reset (
512-external-form-reset). Withnameset, an empty multiple select keeps one unnamed mirror (the reset anchor) whether or not it isrequired, so the rootformprop keeps the reset association after the user clears every value (see Native forms).
Control size amendment
Important
Approved 2026-12-03 by @zprue743. This amendment adds a size prop to the themed GhostSelectTrigger. The contract decision records the chosen options. Target release: 0.4.0.
Why a size option
The themed trigger is one medium control tall (control.size.md.min). In a toolbar of size="sm" buttons and inputs it is taller than its neighbours. <GhostSelectTrigger size="sm"> compiles without a type error today and is ignored, because size falls through as an attribute.
The same gap exists on GhostSegmentedControl, GhostToggleGroup and GhostTabsList. Each spec carries a matching amendment, so all four follow GhostButton and GhostInput, which already take size: 'sm' | 'md' | 'lg'.
Public API
Themed GhostSelectTrigger in @ghostvue/themes only:
| Prop | Type | Default | Contract |
|---|---|---|---|
size | 'sm' | 'md' | 'lg' | 'md' | Trigger height, minimum width, label size and padding follow control.size.<size>, matching a GhostButton or GhostInput of the same size. |
- The union is exported as
GhostSelectTriggerSize, followingGhostButtonSizeandGhostInputSize. - The wrapper renders
data-size="sm"ordata-size="lg"on the trigger and omits it formd, asGhostButtonandGhostInputdo. The wrapper consumessize, so it never reaches the DOM as asizeattribute. data-sizeon the trigger is the styling hook. A headlessGhostSelectTriggerinside.ghost-themethat setsdata-sizeitself gets the same sizing, as withGhostButton.GhostSelect,GhostSelectContentand options take nosize. The open listbox keeps its current option sizing. Select width stays out of scope here.- Headless
@ghostvue/vuedoes not change: no prop, type or manifest change.
Sizing contract
For each size, S below means control.size.<size>.
- Height. Each trigger has
min-block-size: S.min, so it matches aGhostInputorGhostButtonwith the samesizein the same density.min-inline-sizealso readsS.min, so an empty trigger stays at least square. - Label and padding. Font size is
S.font; block and inline padding areS.padding.blockandS.padding.inline. - Tokens only. No recipe sets its own height, padding or pixel value. Densities change
S.*and the control follows. - Coarse pointers. The generated tokens set
sm,mdandlgto the same 44px minimum under(pointer: coarse)in every density, sosmnever shrinks a touch target. - Device scale factor 2. The trigger has no subtracted minimum and measured 36px at both 1x and 2x on the playground example
select/themed. The parity case still runs at 2x.
Accessibility
Roles, names, states, keyboard and focus do not change. The trigger is the activation target and carries the full control height, so sm in compact density (28px) stays above the 24px WCAG 2.2 target-size minimum (2.5.8). Coarse pointers keep the 44px minimum.
Implementation acceptance cases
- Size parity (browser). A playground fixture renders one row per density (
compact,comfortable,spacious). Each row holdsGhostButton,GhostInputand aGhostSelectwith its trigger atsm,mdandlg. At every size and density, the trigger's border-box block size equals theGhostInputof the same size (difference under 0.5px). One fixture serves all four amended components. - Device scale factor 2. The parity comparison also runs in Chromium at
deviceScaleFactor: 2. - Listbox unchanged. Opening an
smorlgselect renders options at the same size as withmd. - Default unchanged. Omitting
sizerenders nodata-size. Theselect/themedexample renders as it does today. - Coarse pointer. With
isMobileandhasTouch, every activation target is at least 44px tall at every size. - Wrapper (unit).
size="sm"andsize="lg"render the matchingdata-size;mdand an omittedsizerender none. Nosizeattribute reaches the DOM. A type test rejectssize="xl"onGhostSelectTrigger. - Manifests and API tables.
pnpm manifests:writerecords the prop inpackages/themes/manifests/ghost-select.manifest.json, andpnpm docs:api:writeupdates the generated API table.
Documentation plan
- A Size section in
docs/components/select.mdwith one runnable example showing a select atsize="sm"beside a smallGhostButtonandGhostInput. - Generated API tables and the themed manifest list the prop.
- A
@ghostvue/themesChangeset.
Compatibility
Additive. The default stays md. Today a size attribute on the themed trigger falls through to the host. On the default button host it has no effect. When as is a component that declares its own size prop, that component receives it today; after the change the wrapper consumes size (see Q3). Minor Changeset for @ghostvue/themes.
Contract decision
Recorded 2026-12-03. @zprue743 took the recommended option for each question, and Q1, Q2 and Q4 have the same answer in all four amended specs. Each question lists the chosen option first and the rejected alternative after it.
- Q1 — Where
sizelives. Chosen: onGhostSelectTrigger, the part that sits in the toolbar. Rejected: onGhostSelect, passed to the trigger through the existing select context. - Q2 — Themed only. Chosen:
sizebelongs to the themed wrappers, as forGhostButtonandGhostInput. Headless components stay unstyled anddata-sizeis the styling hook. Rejected: addsizeto the headless props as a data attribute only. - Q3 — A component
ashost. Chosen: the wrapper consumessizeand does not forward it to a componentashost; the Changeset says so. Rejected: also forwardsizewhenasis a component, so a host that declaressizekeeps receiving it. - Q4 — Release and delivery. Chosen:
0.4.0, with all four components in one implementation change so they share the parity fixture. Rejected: one change per component, in the order segmented control, toggle group, select trigger, tabs.
Narrowed v-model typing amendment
Important
Approved 2026-12-04, no target release yet. The maintainer approved the recommended option for each of Q1–Q3 in PR #775. This amendment narrows the scalar update:modelValue payload from string | undefined to string when the select cannot emit undefined, so that v-model on a string ref compiles under vueCompilerOptions.strictTemplates. Only public types change, not runtime behavior. It delivers the contract and acceptance cases; the implementation waits for a target release. The Slider amendment is approved alongside it, and the two share the strict-templates fixture described in the TypeScript standard.
Problem
A scalar GhostSelect, headless or themed, emits string | undefined. A select that always holds a value, bound to ref<string>, is a common shape, and under strict templates it fails. The ModelUnions.vue fixture in packages/themes/type-tests-strict/ reports, on the current master:
ModelUnions.vue(20,33): error TS2322: Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
ModelUnions.vue(21,25): error TS2322: Type 'string | undefined' is not assignable to type 'string'.Line 20 is the headless select and line 21 the themed one. The repo's own reset test, "restores defaultValue on native form reset" in GhostSelect.test.ts, works around the same union with next ?? ''.
Where undefined comes from
GhostSelect has no clear button, so the question is which paths can emit undefined. In scalar mode use-ghost-select.ts has three writes to the selection:
select(value)from an option, which always writes the option's string.- Native form reset (
applyFormReset), which writesdefaultValuewhen it is a string andundefinedotherwise. This runs in controlled mode too. - The writable
selectedValueref on the single-mode context. Only the library's own parts can reach it:GhostSelectContextis an exported type, butghostSelectContextKeyis not exported.
Unregistering an option never changes the selection (v-model contracts). So the only path to undefined is a form reset of a select whose defaultValue is not a string. A select with a string defaultValue never emits undefined, whether it is controlled or not. That is the condition this amendment types. "Cannot be cleared" here means "has a string reset target", since the user has no other way to clear it.
Options considered
| Option | Strict v-model on ref<string> | Cost and risk |
|---|---|---|
A. Second type parameter keyed on a string defaultValue (recommended) | Compiles when default-value is a string | No new prop and no runtime change. The template states the reset target, which a form needs anyway. The fixture's select lines gain default-value. |
B. New boolean prop, such as clearable (default true), as the discriminator | Compiles with :clearable="false" | Needs new runtime behavior: with false and no string defaultValue, form reset has to restore something other than "no selection". That departs from native <select> reset, and the name suggests a clear button that does not exist. |
C. Infer the payload from the modelValue type (generic="T extends string | undefined") | Compiles with no template change | Unsound. A form reset with no defaultValue writes undefined into a ref<string>. |
D. Use required as the discriminator | Compiles with required | Unsound. required only adds constraint validation, and a form reset still clears the select. |
E. Change runtime so that a reset with no defaultValue keeps a controlled value | Compiles with no template change | Behavior change that breaks reset parity with native controls and GhostInput, and a published contract ("form reset restores the current defaultValue"). |
F. Keep the union and document ref<string | undefined> | Fails | No change, but the strict-templates gap stays. |
Proposed contract
Headless SFC.
GhostSelect.vuegains a second type parameter:generic="Multiple extends boolean = false, Seed extends GhostSelectValueInput<Multiple> | undefined = undefined".Seedis the type ofdefaultValue. Its default,undefined, applies whendefaultValueis omitted.defaultValuetype. In the props passed to the SFC,defaultValueis typeddefaultValue?: Seed, without| undefined. A draft prototype showed that withSeed | undefined, TypeScript dropsundefinedfrom a boundstring | undefinedvalue and infersstring, which would narrow unsoundly. ThewithDefaultsentry fordefaultValueis dropped, since an omitted optional prop isundefinedat runtime anyway.Helper types, extended with defaults so that existing uses keep their meaning:
ts/** Value emitted by `update:modelValue` for a {@link GhostSelect} root. */ export type GhostSelectModelValue< Multiple extends boolean = false, Seed = undefined, > = Multiple extends true ? string[] : Seed extends string ? string : string | undefined /** Props accepted by {@link GhostSelect}. */ export interface GhostSelectProps< Multiple extends boolean = false, Seed extends GhostSelectValueInput<Multiple> | undefined = GhostSelectValueInput<Multiple> | undefined, > { // … unchanged members … defaultValue?: Seed }The conditional distributes, so a
string | undefinedseed givesstring | undefined.Emit.
'update:modelValue': [value: GhostSelectModelValue<Multiple, Seed>]. The one cast this needs, from the composable's payload to the narrowed one, sits at the emit call with a comment naming the reset invariant above.Contract wording. The
defaultValuerow in Props and configuration adds that, in controlled mode too,defaultValueis the form reset target. The runtime already works this way and the reset test above covers it.Unchanged.
modelValuekeeps acceptingstring | undefined.useGhostSelect,UseGhostSelectOptions(itsonValueChangestays wide),GhostSelectValueInput, the context types,GhostSelectExposed, and all multiple-mode types.Themed wrapper. The themed
GhostSelectalready has a generic setup signature and a hand-written construct signature forMultiple. Both gainSeedin the same way.
| Template (scalar) | Seed | update:modelValue payload |
|---|---|---|
<GhostSelect v-model="region"> | undefined | string | undefined (unchanged) |
<GhostSelect v-model="region" default-value="us-east"> | 'us-east' | string |
<GhostSelect default-value="us-east"> | 'us-east' | string |
<GhostSelect v-model="region" :default-value="seed"> (string | undefined) | string | undefined | string | undefined (unchanged) |
<GhostSelect multiple v-model="labels"> | n/a | string[] (unchanged) |
Rejected at compile time under strict templates, with region: Ref<string>:
<GhostSelect v-model="region">: a reset can still clear it.<GhostSelect v-model="region" :default-value="seed">withseed: string | undefined.
A prototype of this contract on the headless and themed roots was checked with the repo's vue-tsc (3.3.14) while drafting. Every row above behaved as listed, and multiple bindings to ref<string[]> still compiled. The prototype was not kept.
Backwards compatibility
- A
ref<string | undefined>bound withv-modelcompiles in every row, as today. So do handlers typed(value: string | undefined) => void. h(GhostSelect<false>, …),GhostSelectProps<true>, andGhostSelectModelValue<false>keep compiling and keep their meaning, since the new parameter has a default.- Multiple mode and the
booleanmultipleunion are unchanged. InstanceTypeis unaffected: the headless root is already a generic SFC, and the themed root keeps its construct signature.- Runtime behavior, DOM, and form submission do not change.
Accessibility
None. Roles, names, keyboard behavior, focus, and form validation are unchanged.
Implementation acceptance cases
These cases gate the implementation, not this amendment.
- The two select lines of
ModelUnions.vuegaindefault-value="us-east"(see Q2) and then pass.KNOWN_GAPSinscripts/strict-templates-baseline.mjsdrops by two, anddocs/standards/typescript.md#stricttemplatesrecords the new counts. - Under strict templates, for both the headless and the themed root: every row in the table compiles with a matching ref type, a
ref<string | undefined>compiles in every row, and both rejected forms fail withTS2322(negative type tests). - The existing
GhostSelectConsumertype tests in both packages pass unchanged, including the explicitGhostSelect<false>instantiation and everymultiplerow. - A Vue test locks the invariant the type relies on: a controlled select with a string
defaultValueemits that string, neverundefined, on form reset. The existing reset test drops itsnext ?? ''workaround. pnpm manifests:writeandpnpm docs:api:writerun, and the manifest description fordefaultValuementions the narrowing.AllComponents.tsstill passes for both roots.- A Changeset for
@ghostvue/vueand@ghostvue/themesdescribes the narrower payload as a type-only change.
Documentation plan
docs/components/select.mdexplains, in a sentence, that a stringdefault-valuemakes thev-modeltypestring, and why.- Examples whose ref is never meant to be empty may switch to
ref<string>withdefault-value. Examples that start empty keepref<string | undefined>.
Decisions for the maintainer
Resolved 2026-12-04. The maintainer approved the recommended option for each question. The alternatives stay listed as the record of what was considered.
- Q1 — Discriminator. Recommended: A, a type parameter keyed on a string
defaultValue. Alternatives: B (a new boolean prop with new reset behavior) or F (keep the union). - Q2 — Fixture. Recommended: add
default-valueto the select lines ofModelUnions.vue, because a sound narrowing needs something in the template that rules out a reset toundefined. Alternative: keep the fixture as written, which only C or E can satisfy (C is unsound and E changes runtime behavior). - Q3 — Release. Recommended: one implementation change with the Slider amendment, with minor Changesets for both packages, in a release the maintainer picks. Alternative: ship each component on its own.