Skip to content
v0.2.10

Select

A Flood choice field with its own popup and native form integration.

Preview

Use Select

Select 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
select.tsxTSX
"use client";

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

export function Example() {
  return (
    <FloodRoot>
      <Field label="Visibility">
        {(control) => (
          <Select {...control} name="visibility" defaultValue="private">
            <option value="private">Private</option>
            <option value="team">Team</option>
          </Select>
        )}
      </Field>
    </FloodRoot>
  );
}

Design notes

  • Single selection uses a Flood trigger and listbox, including the popup. Native options and optgroups supply the choices; disabled choices cannot be selected.
  • Use arrows, Home/End and typing to navigate; Enter or Space confirms, Escape cancels. The popup scrolls active choices into view.
  • Select fills its Field; constrain the form or field wrapper. Multiple and numeric size greater than one use a native inline listbox rather than a popup.
  • A native form bridge preserves name, value/defaultValue, required, disabled, onChange and HTMLSelectElement ref. Inspect the matching guide for the visible focus contract.

API reference

PropValuesDefault
status"error" | "warning" | "success" | "info"—
invalidboolean—
controlSize"sm" | "md" | "lg" | "xl""md"
Native HTML propsSelectHTMLAttributes<HTMLSelectElement>Forwarded
View TypeScript source