Skip to content
v0.2.10

RadioGroup

A named single-choice group with native radio keyboard and form behavior.

Preview
Visibility

Use RadioGroup

RadioGroup 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
radio-group.tsxTSX
"use client";

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

export function Example() {
  return (
    <FloodRoot>
      <RadioGroup name="visibility" legend="Visibility" options={[{ value: "private", label: "Private" }, { value: "team", label: "Team" }]} defaultValue="private" />
    </FloodRoot>
  );
}

Design notes

  • Composes Fieldset and existing native choice controls. The ref targets HTMLFieldSetElement; options need unique values and visible labels.
  • value/onValueChange is controlled; defaultValue initializes an uncontrolled group. Native form reset restores uncontrolled defaults without firing onValueChange; controlled values remain owned by the host.
  • name belongs to the inputs. The form prop associates every input with an external form. Disabled options and groups follow native submission rules.
  • RadioGroup supports native required. CheckboxGroup returns repeated name/value entries; validate minimum/maximum selections in the host and explain errors through status/message.

API reference

PropValuesDefault
legendReactNodeRequired
legendSize · 0.2.10"label" | "section"—
hideLabel · 0.2.3boolean—
hintReactNode—
errorReactNode—
messageReactNode—
status"error" | "warning" | "success" | "info"—
namestringRequired
optionsreadonly ChoiceOption[]Required
valuestring—
defaultValuestring—
onValueChange(value: string) => void—
orientation"vertical" | "horizontal""vertical"
requiredboolean—
Native HTML propsOmit<FieldsetHTMLAttributes<HTMLFieldSetElement>, "children" | "defaultValue" | "role">Forwarded
View TypeScript source