# Radio Group

A group of mutually exclusive radio buttons.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).



<ComponentPreview name="radio-group/Basic" />

## Import [#import]

```rust
use maccn::{MacRadio, MacRadioGroup};
```

## Usage [#usage]

```rust
MacRadioGroup::new("options")
    .axis(Axis::Vertical)
    .gap(8.)
    .child(MacRadio::new("opt1").checked(true).child("Option 1"))
    .child(MacRadio::new("opt2").child("Option 2"))
    .child(MacRadio::new("opt3").child("Option 3"));
```

## Horizontal [#horizontal]

<ComponentPreview name="radio-group/Horizontal" />

```rust
use gpui::Axis;
use maccn::{MacRadio, MacRadioGroup};

let selected = self.radio_selected;

MacRadioGroup::new("radios-horizontal")
    .axis(Axis::Horizontal)
    .child(
        MacRadio::new("radio-h-0")
            .checked(selected == 0)
            .on_change({ ... })
            .child("Yes"),
    )
    .child(
        MacRadio::new("radio-h-1")
            .checked(selected == 1)
            .on_change({ ... })
            .child("No"),
    )
```

## Sizes [#sizes]

<ComponentPreview name="radio-group/Sizes" />

```rust
use maccn::{MacControlSize, MacRadio, MacRadioGroup};

MacRadioGroup::new("radios-sizes")
    .size(MacControlSize::Small)
    .child(MacRadio::new("radio-s").checked(true).child("Small"))
    .child(MacRadio::new("radio-s2").child("Choice"))
```

## Disabled [#disabled]

<ComponentPreview name="radio-group/Disabled" />

```rust
use maccn::{MacRadio, MacRadioGroup};

MacRadioGroup::new("radios-disabled")
    .child(MacRadio::new("radio-d1").disabled(true).child("Disabled"))
    .child(
        MacRadio::new("radio-d2")
            .checked(true)
            .disabled(true)
            .child("Disabled selected"),
    )
```

## API [#api]

### MacRadioGroup Props [#macradiogroup-props]

| Prop   | Type             | Default    |
| ------ | ---------------- | ---------- |
| `size` | `MacControlSize` | `Regular`  |
| `axis` | `Axis`           | `Vertical` |
| `gap`  | `f32`            | `8.0`      |

### MacRadio Props [#macradio-props]

| Prop       | Type             | Default   |
| ---------- | ---------------- | --------- |
| `size`     | `MacControlSize` | `Regular` |
| `checked`  | `bool`           | `false`   |
| `disabled` | `bool`           | `false`   |

### Events [#events]

| Event       | Payload                                      |
| ----------- | -------------------------------------------- |
| `on_change` | `(bool, &ClickEvent, &mut Window, &mut App)` |
