Skip to content

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 size prop on the themed GhostSelectTrigger is 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:modelValue type for a select with a string defaultValue is 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, GhostSelect selects one value.
  • Combobox with free text entry, filtering, or async search. Use GhostInput or a future searchable combobox.
  • GhostDropdownMenu action-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 input
  • GhostSelectTrigger — role="combobox" anchor
  • GhostSelectValue — selected label / placeholder slot
  • GhostSelectContent — portaled listbox surface
  • GhostSelectOption — role="option" item
  • GhostSelectGroup — optional role="group" wrapper
  • GhostSelectLabel — group label (id for aria-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) ​

PropTypeDefaultContract
modelValuestring | undefinedundefinedControlled selected value. undefined is uncontrolled.
defaultValuestring | undefinedundefinedInitial value when uncontrolled; omitted means no selection. Form reset restores the current defaultValue.
namestringundefinedVisually hidden input name for native submit. When omitted, the control does not submit.
disabledbooleanfalseDisables trigger and options; omits value from submit.
requiredbooleanfalseNative required and constraint validation on the submit input when name is set (not type=hidden).
invalidbooleanfalseSets aria-invalid on the trigger for Field integration.
openboolean | undefinedundefinedControlled listbox open state. Omit for uncontrolled.
defaultOpenbooleanfalseInitial open state when open is omitted.
placeholderstringundefinedPlaceholder 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 ​

PropTypeDefaultContract
asstring | Component'button'Focusable combobox host. Native button uses type="button".
disabledbooleanfalseDisables open/close and selection. Combines with root disabled.

GhostSelectValue ​

PropTypeDefaultContract
———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 ​

PropTypeDefaultContract
asstring | Component'div'Listbox host.
placementPlacement'bottom'Passed to useFloating.
offsetsame as PopoverundefinedFloating offset.
flip / shift / strategysame as Popoverdefaults match PopoverCollision handling.
portalbooleantrueGhostPortal when open.
portalToGhostPortalTarget'body'Teleport target.

GhostSelectOption ​

PropTypeDefaultContract
valuestring—Stable option value; unique within the root.
disabledbooleanfalseSkipped by pointer, keyboard, and typeahead.
textValuestring—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 ​

RolePropEmitUncontrolled initial
SelectedmodelValueupdate:modelValuedefaultValue or none
Openopenupdate:opendefaultOpen

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 ​

  • GhostSelect default slot holds trigger, value, content, and options.
  • GhostSelectValue default slot renders only when a value is selected and replaces the selected label. The named placeholder slot renders only when nothing is selected and replaces root placeholder.
  • Exposed template refs (each part): { element: HTMLElement \| null, focus(), blur() }.
  • GhostSelect exposed: element on hidden input when present, else trigger; focus() focuses the trigger. In multiple mode element is the current first form mirror (see Native forms).

State model ​

SurfaceAttribute / state
Triggerdata-part="trigger", data-state="open" | "closed"
Contentdata-part="content", data-state="open" | "closed", data-placement while open, hidden while closed
Optiondata-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, optional aria-invalid, aria-required when root required.
  • GhostSelectContent: role="listbox" and aria-labelledby → trigger id unless overridden. While open the listbox container has tabindex="-1". While closed it has no tabindex and carries aria-hidden="true" and inert (see State model).
  • GhostSelectOption: role="option", aria-selected, roving tabindex via useRovingFocus (orientation: vertical).
  • Groups: role="group" + aria-labelledby.

Keyboard ​

KeyWhereBehavior
Enter / Space / ArrowDown / ArrowUpTrigger (closed)Opens listbox; focus moves to selected enabled option or first/last enabled option for Up/Down.
EscapeContentCloses listbox; focus returns to trigger.
TabContentCloses listbox; default tab navigation.
Arrow keys / Home / EndContentuseRovingFocus among enabled options.
Printable keysContentTypeahead: accumulate within ~500ms, match textValue prefix, cycle matches; focus moves to match.
Enter / SpaceFocused optionSelects 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 useRovingFocus with 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 + useFocusScope trapped: false, matching Popover).
  • visibility: hidden on content until useFloating().isPositioned is 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 ​

  • useGhostId for 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 when name is set (overlay-ssr.test.ts asserts the closed role="listbox").
  • Trigger text in SSR: GhostSelectOption registers its label only in client lifecycle callbacks, and GhostSelectValue serializes before the option subtree, so the server-rendered trigger shows the raw value. A default-closed select with value a and option label Apple renders a on the server. After hydration the mounted options register and the trigger text becomes Apple without an emit or a model change. Labels resolve without opening once options register on the client.
  • defaultOpen: true may render listbox through deferred GhostPortal without touching window/document in setup; browser listeners attach in onMounted (overlay-ssr.test.ts pattern).

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 open
  • useGhostId — ids
  • useNativeFormReset + visually hidden input[type="text"] — submit, required, and reset (aria-hidden so axe ignores the mirror; the combobox trigger is the accessible control)
  • useFloating, GhostPortal, useDismissableLayer, useFocusScope — overlay
  • useRovingFocus — 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, keyCode 229) skip typeahead, roving, selection, and Escape, and typeahead resumes afterwards
  • SSR: overlay-ssr.test.ts closed/open; expectSsrHydration integration; a distinct trigger-text assertion on the trigger element itself, not anywhere in the HTML: with a default-closed value a and option label Apple, the server string shows the raw value a, and after hydrating that markup and awaiting option registration it shows Apple. Hydration and registration emit no update:modelValue.
  • E2E + axe: open/select/close keyboard paths, form submit, docs example, real focus / typeahead / selection in rendered order after list changes, WebKit-style keyCode 229 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 with Escape; the widget state must not change until the composition is committed, and the first keys after commit must behave normally.
  • Visual: examples/select/themed baselines via pnpm 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 the GhostSelectValue slot. Rules such as "choose at most three" belong to GhostForm (#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 GhostCombobox multiple behavior. 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)

vue
<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)

vue
<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

vue
<!-- 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:

ts
/** 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
TemplateMultiplemodelValue / defaultValue acceptedupdate:modelValue payload
<GhostSelect v-model="region">falsestring | undefinedstring | undefined (unchanged)
<GhostSelect default-value="us-east">falsestring | undefinedstring | undefined (unchanged)
<GhostSelect multiple v-model="labels">truereadonly string[] | undefinedstring[]
<GhostSelect multiple :default-value="['bug']">truereadonly string[] | undefinedstring[]
<GhostSelect :multiple="isMulti"> (isMulti: boolean)booleanstring | readonly string[] | undefinedstring | string[] | undefined

Rejected at compile time (type regression fixtures):

  • <GhostSelect v-model="labels"> with labels: Ref<string[]> and no multiple: the array is not a string.
  • <GhostSelect :default-value="['bug']"> without multiple.
  • <GhostSelect multiple default-value="bug"> and <GhostSelect multiple v-model="region"> with region: 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) ​

PropTypeDefaultContract
multipleMultiple (boolean)falseSelects the multiple model. Read once at setup (S7).
modelValueGhostSelectValueInput<Multiple> | undefinedundefinedMultiple: controlled readonly string[]. undefined is uncontrolled, as in single mode. [] is the controlled empty value.
defaultValueGhostSelectValueInput<Multiple> | undefinedundefinedMultiple: uncontrolled seed, copied at setup and again at form reset. Omitted means [].
messagesGhostSelectMessagesundefinedAdds 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) ​

SlotProps (both modes)Rendered when
default{ values: readonly string[]; labels: readonly string[] }At least one value is selected.
placeholdernoneNothing 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). GhostSelectContext is a union keyed by a plain, setup-fixed multiple literal (S7), not a ref, so TypeScript can narrow on it:

    ts
    interface 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 | GhostSelectMultipleContext

    GhostSelectContextBase holds every other existing field plus selectedValues. Reads work without narrowing (ctx.selectedValue.value is string | readonly string[] | undefined). Writes are mode-safe: under a multiple root selectedValue.value = 'bug' (or any assignment) fails with TS2540 because the ref is readonly, and under a narrowed single root selectedValue.value = ['bug'] fails with TS2322. An unnarrowed assignment also fails, since value is readonly in one branch, so a single-mode write has to narrow on ctx.multiple === false first.

  • 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 leaves open alone, matching GhostCombobox's select.

  • Write path. In single mode, context consumers change the selection through select(value) or, after narrowing, by assigning selectedValue.value (unchanged). In multiple mode they use select(value) (toggle) or replaceSelection(values), which replaces the whole selection. replaceSelection copies the given array into a new, duplicate-free string[] 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.

  • formInputProps stays the single-mode object. A new formInputs: ComputedRef<GhostSelectFormInputProps[]> lists one mirror per value in multiple mode, or one unnamed reset anchor when name is 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 copies defaultValue at 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.selectedValue and selectedValues expose the current array as readonly 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 through select(value) or replaceSelection(values), which copies (see useGhostSelect).
  • Empty value. []. Multiple mode never emits undefined. A controlled parent that passes undefined makes 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" for required, and its keyboard path ignores an option whose data-value is 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 (value must be unique within the root).

Selection ordering (S2) ​

The model is kept in selection order:

  1. Selecting a value appends it: ['bug'] then Docs gives ['bug', 'docs'].
  2. Deselecting removes it and keeps the rest in place: toggling Bug off gives ['docs'].
  3. Reselecting appends again: ['docs', 'bug'].
  4. 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 ​

StateOwnerChanges when
Selected setmodelValue (controlled) or internal copyUser toggles an option, native form reset, or the parent's controlled value.
Openopen (controlled) or internalTrigger, Escape, Tab, outside pointer. Toggling never changes open.
Active optionDOM focus inside the listboxArrow 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.
  • GhostSelectValue keeps the last registered textValue for 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"), so Escape and Tab still 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 disabled disables the trigger and every option. The value text still renders. All form mirrors, including the empty reset anchor, are disabled, so nothing submits.

Accessibility contract (multiple) ​

Semantics ​

ElementSingle mode (published)Multiple mode (proposed)
GhostSelectTriggerrole="combobox", aria-haspopup="listbox", aria-expanded, aria-controlsSame attributes. No aria-multiselectable on the combobox (not a supported state there).
Listboxrole="listbox", aria-labelledby → triggerAdds aria-multiselectable="true" whenever the listbox renders, open or closed (hidden).
GhostSelectOptionaria-selected="true" on the value, "false" on the restaria-selected="true" on every member and "false" on every other option, so screen readers announce "not selected" too.
Disabled optionaria-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:

KeyWhereSingle mode (published, regression-tested)Multiple mode (proposed)
Enter / Space / ArrowDown / ArrowUpTrigger (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.
SpaceFocused optionSelects, closes, focuses trigger.Toggles the option. List stays open; focus stays on the option.
EnterFocused optionSelects, closes, focuses trigger.Toggles, like Space (S3).
Arrow keys / Home / EndListboxMoves focus among enabled options.Same; never changes selection.
Printable keysListboxTypeahead moves focus.Same; never changes selection.
EscapeListboxCloses; focus to trigger.Same. Selection made while open is kept.
Tab / Shift+TabListboxCloses; 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 open stays parent-owned; toggling never emits update: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 ​

ModelDefault GhostSelectValue text (S4)data-state on value part
[]placeholder slot, else root placeholdernone
['bug']Bugchecked
['docs', 'bug']Docs, Bug (model order, listSeparator)checked
['bug', 'gone'], gone never registeredBug, 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.

vue
<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>
ts
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 selected

The root form prop associates the control with a form it is not inside:

vue
<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>
ts
// 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 from GhostCombobox multiple, which submits one empty mirror (['']); the combobox is not changed by this proposal.
  • Required. Validity is decided by membership, not order: a required multiple select is satisfied when the selection has at least one member other than '', matching single mode, which treats '' as no selection. required goes 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, as useGhostSelect.syncFormValidity does in single mode: when no member other than '' exists, the required-bearing mirror gets setCustomValidity(messages.required) and its empty value also fails valueMissing, so it blocks submit and focuses the trigger. Otherwise the required-bearing mirror's custom validity is cleared with setCustomValidity(''), so a satisfied collection has no customError. 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 with messages.required.
  • Reset. Native form reset restores a copy of the current defaultValue (or []) and emits update:modelValue only when membership or order differs from the current value, matching single mode's no-op on an equal value.
  • Reset with an external form. useNativeFormReset matches a reset event against the owner form of the element it is given, reading element.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 root form prop, so its owner is only its ancestor <form>. Multiple mode passes the first mirror, which with name set is always present (a member mirror or the reset anchor). Its form attribute therefore keeps the association after the user clears every value, and an external form.reset() restores a nonempty defaultValue. 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 still disabled under root disabled; a disabled input keeps its form owner, 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 root form prop has no effect.
  • Exposed element. GhostSelect's exposed element is the same element useNativeFormReset uses: the current first mirror (the first member mirror in model order, or the reset anchor when the selection is empty), else the trigger when name is not set. It is read when accessed, so it follows the first mirror as the selection changes: with ['bug', 'docs'] it is the bug mirror, after toggling bug off it is the docs mirror, and after clearing every value it is the reset anchor. It is never a later mirror and never the trigger while name is 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 native button trigger, 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 no name and is kept whether or not the select is required (the reset anchor).
  • The generic setup overload pattern from the themed GhostDataTable wrapper for the themed GhostSelect (S6). Its runtime update:modelValue validator must also accept string[].

No new package, dependency, or shared primitive.

Multiple selection test plan ​

  • Vue unit tests (multiple): toggle on and off by click, Space, and Enter; 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 keeps aria-selected on 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's replaceSelection emits a new, duplicate-free array and leaves the passed array unchanged; [] vs undefined; defaultValue copied 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); root disabled; required with the unnamed empty mirror; required with a controlled ['', 'bug'] and with ['bug', ''] is valid in both orders (required is on the bug mirror), and [''] is invalid; a required ['bug'] passes checkValidity() with validity.customError false on every mirror, and toggling the last nonempty member off sets messages.required on the anchor, while toggling one back on clears it; a required controlled [''] updated to ['', 'bug'] passes checkValidity() with validity.customError false on the still-mounted '' mirror; optional empty select with name renders exactly one unnamed reset anchor carrying form; external-form reset: with the root form prop pointing at a form the select is not inside and a nonempty defaultValue, clear every option, assert getAll(name) is [] and the anchor has no name, call that form's reset(), await the reset deferral, and assert the default is restored (one emit, new array) and getAll(name) equals it; a reset on the ancestor form of the trigger does not reset an externally associated select; exposed element: with name and ['bug', 'docs'] it is the bug mirror, after toggling bug off it is the docs mirror, after clearing every value it is the unnamed reset anchor, after toggling bug back on it is the bug mirror, and without name it is the trigger; IME keys ignored for toggles; GhostSelectValue slot props and listSeparator; a controlled ['bug', 'bug'] passes slot props values: ['bug'] and labels: ['Bug'] and renders the default text Bug once, without an emit.
  • Single-select regressions (must pass unchanged): every existing GhostSelect.test.ts, select-combobox-*.test.ts, and ghost-select*.test.ts case; plus explicit assertions that single Space / Enter still select, close, and focus the trigger; the listbox has no aria-multiselectable; unselected options keep aria-selected="false"; empty single still submits ['']; GhostSelectValue default slot without props renders unchanged; with no selection only the named placeholder slot renders (else root placeholder), and the default slot renders only after a selection; the closed listbox has no tabindex and the open listbox has tabindex="-1".
  • Type tests: new packages/vue/type-tests/GhostSelectConsumer.ts and .vue covering every row of the type inference table, and packages/vue/type-tests-negative cases for each rejected form. The single-mode cases (v-model with Ref<string | undefined>, default-value="…", update:modelValue payload string | undefined) are the regression fixture for existing consumers. Same cases against the @ghostvue/themes wrapper. Context type cases (S6 revision): after narrowing on ctx.multiple, a multiple context rejects selectedValue.value = 'bug' and any other assignment (TS2540) and selectedValue.value.push(…) (TS2339). A single context rejects selectedValue.value = ['bug'] (TS2322). An unnarrowed assignment is rejected, and ctx.replaceSelection is rejected before narrowing to multiple. Accepted: unnarrowed reads as string | readonly string[] | undefined, select(value), replaceSelection(frozenArray) on a multiple context, and selectedValue.value = 'a' or undefined on a narrowed single context.
  • SSR, closed: a default-closed multiple select with defaultValue: ['bug'] renders the hidden listbox (role="listbox" inside hidden content, 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 value bug. After hydrating that markup and awaiting option registration, the trigger text is the label Bug. Hydration and registration emit nothing.
  • SSR, open: with defaultOpen: true, the rendered listbox has aria-multiselectable="true", members have aria-selected="true", and other options have aria-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 after form.reset(); the same sequence for a select associated through the root form prop with a form it is not inside (clear every option by pointer, getAll(name) is [], call that form's reset(), the nonempty default is restored in the trigger text and getAll(name)); axe with the list open and closed. The existing tests/e2e/select.spec.ts single-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 showing FormData.getAll and reset (examples/select/multiple-form.vue), both listed in the manifest.
  • Guidance on choosing between multiple GhostSelect, GhostComboboxmultiple, and GhostCheckboxGroup.
  • Generated API tables via pnpm manifests:write and pnpm docs:api:write (multiple prop, GhostSelectValue slot props, emit payload).
  • Playground section with test ids for the browser tests.

Multiple selection compatibility ​

  • Additive at runtime. multiple defaults to false; single-mode props, emits, keyboard behavior, FormData, and markup do not change.
  • Exported types (S6). GhostSelect becomes generic with Multiple = false as the default, so existing single consumers infer the same types; the type regression fixture proves it. GhostSelectMessages gains an optional field. GhostSelectContext becomes a union discriminated by multiple (S6 revision). This is a type-level change for consumers who use the context directly: reads of selectedValue.value widen to string | readonly string[] | undefined, and single-mode writes must narrow on ctx.multiple === false first. S6 approved changing the context for 0.2.0 over a separate field.
  • Themed wrapper. Gains multiple and the generic overload; its emit validator widens.
  • Changesets. Minor for @ghostvue/vue and @ghostvue/themes in 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.

IDDecisionApproved choiceRejected alternative
S1API shapemultiple 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.
S2Value orderSelection 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.
S3Keyboard and focusEnter 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.
S4Value renderingGhostSelectValue 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.
S5Disabled selected optionsA 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.
S6Exported type surfaceGeneric 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.
S7Changing multiple after mountUnsupported. 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 matches GhostSelectContent: the closed listbox stays mounted and hidden so options register, replacing the earlier v-if="open" sentence. aria-multiselectable is 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 widened GhostSelectContext.selectedValue keeps the array branch readonly (string | readonly string[] | undefined), so the parent's array is never mutated through the context and emitted arrays stay receiver-owned (see useGhostSelect). The S6 context revision below replaces this entry's multiple-mode setter with replaceSelection.
  • Order-independent required validity (Codex review comment 4728793138). required is 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 custom messages.required is set only when no such member exists and is cleared otherwise, so a satisfied collection has no customError (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). zprue743 chose option 2 at a24d616: GhostSelectContext is a union discriminated by multiple. The single branch has a scalar selectedValue. The multiple branch has a readonly-array selectedValue and replaceSelection, 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 with vue-tsc 3.3.14 on a prototype of these types (not committed). Under a multiple root, assigning 'bug' (or any value) fails with TS2540. Under a narrowed single root, assigning an array fails with TS2322. An unnarrowed assignment fails with TS2540. Reads, select, replaceSelection, and narrowed single writes compile. See useGhostSelect.
  • Normalized value slot props (Codex review comment 4728962234). GhostSelectValue slot values are the duplicate-free selectedValues, matching how duplicates count as one member elsewhere (see GhostSelectValue slots).
  • 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 multiple attribute was checked with vue-tsc 3.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 requires tabindex="-1" on the listbox only while open, matching GhostSelectContent and the State model, which says the closed listbox has none.
  • GhostSelectValue slot contract (Codex review comment 4729149834). The published GhostSelectValue row and slot bullet now match the current component: the default slot renders only with a selection and the named placeholder slot 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 mode GhostSelect's exposed element is the current first mirror (a member mirror or the reset anchor), the same element used for form reset, else the trigger without name. A unit test covers the transitions (see Native forms).
  • External-form reset (512-external-form-reset). With name set, an empty multiple select keeps one unnamed mirror (the reset anchor) whether or not it is required, so the root form prop 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:

PropTypeDefaultContract
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, following GhostButtonSize and GhostInputSize.
  • The wrapper renders data-size="sm" or data-size="lg" on the trigger and omits it for md, as GhostButton and GhostInput do. The wrapper consumes size, so it never reaches the DOM as a size attribute.
  • data-size on the trigger is the styling hook. A headless GhostSelectTrigger inside .ghost-theme that sets data-size itself gets the same sizing, as with GhostButton.
  • GhostSelect, GhostSelectContent and options take no size. The open listbox keeps its current option sizing. Select width stays out of scope here.
  • Headless @ghostvue/vue does 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 a GhostInput or GhostButton with the same size in the same density. min-inline-size also reads S.min, so an empty trigger stays at least square.
  • Label and padding. Font size is S.font; block and inline padding are S.padding.block and S.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, md and lg to the same 44px minimum under (pointer: coarse) in every density, so sm never 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 ​

  1. Size parity (browser). A playground fixture renders one row per density (compact, comfortable, spacious). Each row holds GhostButton, GhostInput and a GhostSelect with its trigger at sm, md and lg. At every size and density, the trigger's border-box block size equals the GhostInput of the same size (difference under 0.5px). One fixture serves all four amended components.
  2. Device scale factor 2. The parity comparison also runs in Chromium at deviceScaleFactor: 2.
  3. Listbox unchanged. Opening an sm or lg select renders options at the same size as with md.
  4. Default unchanged. Omitting size renders no data-size. The select/themed example renders as it does today.
  5. Coarse pointer. With isMobile and hasTouch, every activation target is at least 44px tall at every size.
  6. Wrapper (unit). size="sm" and size="lg" render the matching data-size; md and an omitted size render none. No size attribute reaches the DOM. A type test rejects size="xl" on GhostSelectTrigger.
  7. Manifests and API tables. pnpm manifests:write records the prop in packages/themes/manifests/ghost-select.manifest.json, and pnpm docs:api:write updates the generated API table.

Documentation plan ​

  • A Size section in docs/components/select.md with one runnable example showing a select at size="sm" beside a small GhostButton and GhostInput.
  • Generated API tables and the themed manifest list the prop.
  • A @ghostvue/themes Changeset.

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.

  1. Q1 — Where size lives. Chosen: on GhostSelectTrigger, the part that sits in the toolbar. Rejected: on GhostSelect, passed to the trigger through the existing select context.
  2. Q2 — Themed only. Chosen: size belongs to the themed wrappers, as for GhostButton and GhostInput. Headless components stay unstyled and data-size is the styling hook. Rejected: add size to the headless props as a data attribute only.
  3. Q3 — A component as host. Chosen: the wrapper consumes size and does not forward it to a component as host; the Changeset says so. Rejected: also forward size when as is a component, so a host that declares size keeps receiving it.
  4. 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:

text
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 writes defaultValue when it is a string and undefined otherwise. This runs in controlled mode too.
  • The writable selectedValue ref on the single-mode context. Only the library's own parts can reach it: GhostSelectContext is an exported type, but ghostSelectContextKey is 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 ​

OptionStrict v-model on ref<string>Cost and risk
A. Second type parameter keyed on a string defaultValue (recommended)Compiles when default-value is a stringNo 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 discriminatorCompiles 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 changeUnsound. A form reset with no defaultValue writes undefined into a ref<string>.
D. Use required as the discriminatorCompiles with requiredUnsound. 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 valueCompiles with no template changeBehavior 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>FailsNo change, but the strict-templates gap stays.

Proposed contract ​

  • Headless SFC. GhostSelect.vue gains a second type parameter: generic="Multiple extends boolean = false, Seed extends GhostSelectValueInput<Multiple> | undefined = undefined". Seed is the type of defaultValue. Its default, undefined, applies when defaultValue is omitted.

  • defaultValue type. In the props passed to the SFC, defaultValue is typed defaultValue?: Seed, without | undefined. A draft prototype showed that with Seed | undefined, TypeScript drops undefined from a bound string | undefined value and infers string, which would narrow unsoundly. The withDefaults entry for defaultValue is dropped, since an omitted optional prop is undefined at 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 | undefined seed gives string | 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 defaultValue row in Props and configuration adds that, in controlled mode too, defaultValue is the form reset target. The runtime already works this way and the reset test above covers it.

  • Unchanged. modelValue keeps accepting string | undefined. useGhostSelect, UseGhostSelectOptions (its onValueChange stays wide), GhostSelectValueInput, the context types, GhostSelectExposed, and all multiple-mode types.

  • Themed wrapper. The themed GhostSelect already has a generic setup signature and a hand-written construct signature for Multiple. Both gain Seed in the same way.

Template (scalar)Seedupdate:modelValue payload
<GhostSelect v-model="region">undefinedstring | 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 | undefinedstring | undefined (unchanged)
<GhostSelect multiple v-model="labels">n/astring[] (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"> with seed: 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 with v-model compiles in every row, as today. So do handlers typed (value: string | undefined) => void.
  • h(GhostSelect<false>, …), GhostSelectProps<true>, and GhostSelectModelValue<false> keep compiling and keep their meaning, since the new parameter has a default.
  • Multiple mode and the boolean multiple union are unchanged.
  • InstanceType is 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.

  1. The two select lines of ModelUnions.vue gain default-value="us-east" (see Q2) and then pass. KNOWN_GAPS in scripts/strict-templates-baseline.mjs drops by two, and docs/standards/typescript.md#stricttemplates records the new counts.
  2. 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 with TS2322 (negative type tests).
  3. The existing GhostSelectConsumer type tests in both packages pass unchanged, including the explicit GhostSelect<false> instantiation and every multiple row.
  4. A Vue test locks the invariant the type relies on: a controlled select with a string defaultValue emits that string, never undefined, on form reset. The existing reset test drops its next ?? '' workaround.
  5. pnpm manifests:write and pnpm docs:api:write run, and the manifest description for defaultValue mentions the narrowing.
  6. AllComponents.ts still passes for both roots.
  7. A Changeset for @ghostvue/vue and @ghostvue/themes describes the narrower payload as a type-only change.

Documentation plan ​

  • docs/components/select.md explains, in a sentence, that a string default-value makes the v-model type string, and why.
  • Examples whose ref is never meant to be empty may switch to ref<string> with default-value. Examples that start empty keep ref<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.

  1. 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).
  2. Q2 — Fixture. Recommended: add default-value to the select lines of ModelUnions.vue, because a sound narrowing needs something in the template that rules out a reset to undefined. Alternative: keep the fixture as written, which only C or E can satisfy (C is unsound and E changes runtime behavior).
  3. 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.