# RadioGroup A set of radio buttons where only one option can be selected at a time. Use it when you want the user to pick exactly one value from a short list — pricing plans, delivery options, account types. --- ## Quick example ```csharp new RadioGroup( name: "plan", label: "Select a plan", options: new[] { ("free", "Free", true), // pre-selected ("pro", "Pro", false), ("teams", "Teams", false), }) ``` --- ## All the options ```csharp public RadioGroup( string name, IEnumerable<(string Value, string Label, bool Selected)> options, string label = "", string direction = "flex-col") ``` | Parameter | What it does | |---|---| | `name` | The shared form field name for all radio buttons in the group. | | `options` | The list of choices. Each is a `(Value, Label, Selected)` tuple. | | `label` | Optional heading displayed above the options. | | `direction` | `"flex-col"` stacks options vertically (default). `"flex-row"` places them side by side. | **Option tuple fields:** | Field | What it does | |---|---| | `Value` | The string submitted when this option is selected. | | `Label` | The text shown next to the radio button. | | `Selected` | Pre-select this option on render. Only one should be `true`. | --- ## Real-world examples ### Pricing plan selector ```csharp new RadioGroup( name: "plan", label: "Choose your plan", options: new[] { ("free", "Free — up to 3 projects", true), ("pro", "Pro — unlimited projects", false), ("enterprise", "Enterprise — custom pricing", false), }) ``` Reading on the server: ```csharp public record Command([property: FromForm] string Plan); // command.Plan == "free" | "pro" | "enterprise" ``` ### Horizontal size selector ```csharp new RadioGroup( name: "size", label: "Size", direction: "flex-row", options: new[] { ("sm", "S", false), ("md", "M", true), ("lg", "L", false), ("xl", "XL", false), }) ``` ### Options built dynamically from the database ```csharp var options = categories .Select((cat, i) => (cat.Slug, cat.Name, i == 0)) // first option pre-selected .ToArray(); new RadioGroup(name: "category", label: "Category", options: options) ``` --- ## How it works Each option is a `