Atoms / Radio group

Radio group

One choice among a few, all visible. The chosen box holds a square.

import { RadioGroup } from "@forgeron/ui";
/01 → Default
Who can open this tool
import { RadioGroup } from "@forgeron/ui";

export default function Default() {
  return (
    <RadioGroup
      label="Who can open this tool"
      defaultValue="team"
      options={[
        { value: "me", label: "Only me" },
        { value: "team", label: "My team", hint: "Sales, 6 people" },
        { value: "workspace", label: "Everyone in the workspace" },
      ]}
    />
  );
}
/02 → Row
Billing
import { RadioGroup } from "@forgeron/ui";

export default function Row() {
  return (
    <RadioGroup
      label="Billing"
      direction="row"
      defaultValue="monthly"
      options={[
        { value: "monthly", label: "Monthly" },
        { value: "yearly", label: "Yearly" },
      ]}
    />
  );
}
API → Props
PropTypeDefaultDescription
labelReactNode—The question, said once (legend).
options{ value, label, hint?, disabled? }[]—The choices.
value / defaultValuestring—Controlled or not.
onChange(value: string) => void—On a new choice.
direction"column" | "row""column"Stacked or side by side.
namestring—Made up when absent.
classNamestring—Extra classes.