Skip to content
v0.2.10

ListBox

A named single or multiple selection list with native validation and semantic feedback.

Preview
ReactComponent-based interfaces
VueProgressive interfaces
Svelte
Unavailable framework

Use ListBox

ListBox is a named export of @flood-md/react. Connect the package once, then import what you use.

First time here? Connect Flood
Example import style
list-box.tsxTSX
"use client";

import { FloodRoot, ListBox } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <ListBox label="Framework" name="framework" defaultValue="react" options={[{value:"react",label:"React"},{value:"vue",label:"Vue"},{value:"svelte",label:"Svelte"}]} />
    </FloodRoot>
  );
}

Design notes

  • Use a scalar value/defaultValue in single mode and an array in multiple mode. onValueChange returns the matching shape. Stable, unique nonempty option IDs are submitted as repeated hidden native form fields when name is supplied. Uncontrolled reset restores the initial selection.
  • The list owns one Tab stop and aria-activedescendant. Arrows/Home/End move through enabled options; single selection follows navigation. Space/Enter selects or toggles. Typing searches option-label prefixes. Disabled options cannot be selected; readOnly retains navigation and copying without changing the value.
  • Provide a clear label or use hideLabel with the accessible label preserved. Use disabled on the composite to remove its Tab stop. The list is not virtualized and does not fetch options. Available in 0.2.5.
  • required validates accepted selection; readonly bypasses validation and disabled excludes form values.
  • description/message and status share the field feedback contract. validationMessage is a host-owned blocking constraint.

API reference

PropValuesDefault
labelstringRequired
hideLabelbooleanfalse
requiredboolean—
requiredMessagestring—
validationMessagestring—
descriptionstring—
messagestring—
status"error" | "warning" | "success" | "info"—
invalidboolean—
optionsreadonly ComboboxOption[]Required
valuestring | readonly string[]—
defaultValuestring | readonly string[]—
onValueChange(value: string | string[]) => void—
multiplebooleanfalse
selectionBehavior"automatic" | "manual"—
appearance"surface" | "plain"—
disabledbooleanfalse
readOnlybooleanfalse
namestring—
formstring—
controlSize"sm" | "md" | "lg" | "xl""md"
Native HTML propsOmit<HTMLAttributes<HTMLDivElement>, "children" | "role" | "defaultValue" | "onChange">Forwarded
View TypeScript source