# Unselect / clear radio group selection

**URL:** <https://forum.inductiveautomation.com/t/unselect-clear-radio-group-selection/65714>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [October 26, 2022, 5:09pm UTC](https://forum.inductiveautomation.com/t/unselect-clear-radio-group-selection/65714 "2022-10-26T17:09:52Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [October 26, 2022, 5:09pm UTC](https://forum.inductiveautomation.com/t/unselect-clear-radio-group-selection/65714/1 "2022-10-26T17:09:52Z")

</div>

What's the best way to unselect or clear a radio group selection? If I set `props.value` to `""` or `None` or any other value I try, it changes the `value` but the previously selected option is still highlighted. It's a minor problem but still annoying - I'm just looking for a consistent way to accomplish this.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/6/d6c937fe77a27f2adca2a931855215389ed64f5b.png)

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [October 26, 2022, 5:20pm UTC](https://forum.inductiveautomation.com/t/unselect-clear-radio-group-selection/65714/2 "2022-10-26T17:20:17Z")

</div>

try the value **null**

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [October 26, 2022, 5:21pm UTC](https://forum.inductiveautomation.com/t/unselect-clear-radio-group-selection/65714/3 "2022-10-26T17:21:19Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/2/925e07de16fb782631f9c6adab93a985d6ee8062.png)

Tried that...

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [October 26, 2022, 5:28pm UTC](https://forum.inductiveautomation.com/t/unselect-clear-radio-group-selection/65714/4 "2022-10-26T17:28:07Z")

</div>

I see. It seems you have make sure all  
`props.radios[x].selected = false`

Doing this creates a component error (index expects an integer). It's likely this components' design intent is to have a default item selected.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/6/3628e9a4f4b9038be4283fa00db6baf6aabb87a1.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 26, 2022, 6:13pm UTC](https://forum.inductiveautomation.com/t/unselect-clear-radio-group-selection/65714/5 "2022-10-26T18:13:15Z")

</div>

![Radio buttons](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/2/4294ba204aee1b58c5090e7853ff81a65c0db2d9.jpeg)  
_Figure 1. Random eBay photo._

Radio buttons mimic real electro-mechanical radio buttons which typically couldn't be unselected. Pressing one caused it to latch and unlatch the others through a cross-interlock. The software buttons should always have one selected as would be expected GUI standard. For your application you could onsider an additional button labeled 'None' or equivelant.

Ironically the only decent photo I could find shows all the buttons out.

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [October 27, 2022, 1:09am UTC](https://forum.inductiveautomation.com/t/unselect-clear-radio-group-selection/65714/6 "2022-10-27T01:09:12Z")

</div>

> [@code\_skin](#):
>
> It's likely this components' design intent is to have a default item selected

Likely. But it doesn't on startup, as your screenshot shows. I just want to avoid unnecessary confusion for the end user...

I'll see if I can find another way besides looping through the `radios` and setting `selected` to `False`, ~~but for now, I'll mark your post as the answer until/if I find something better.~~ (see below)

- 
- 
- 

**On second thought** , I may be able to clear it without looping, as I will have the `index` of the selected radio, so I could do something like this:

```python
idx = self.getChild("RadioGroup").props.index
self.getChild("RadioGroup").props.radios[idx].selected = False

# after I clear `selected` at index idx, defaults to first radio :(
self.getChild("RadioGroup").props.radios[0].selected = False

# after setting selected on first radio to False, it'll turn True after an instant :(

```

---

<div class="post-metadata">

**Author:** ![hw79](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@hw79](https://forum.inductiveautomation.com/u/hw79)\
**Post date:** [November 27, 2023, 7:31pm UTC](https://forum.inductiveautomation.com/t/unselect-clear-radio-group-selection/65714/7 "2023-11-27T19:31:10Z")

</div>

@YF129701

A bit late to the party, but I found another workaround to set the index outside the number of radios.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/d/7d041e970d61e85d1697e08f57caef29bddb9001.png)

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [November 27, 2023, 9:36pm UTC](https://forum.inductiveautomation.com/t/unselect-clear-radio-group-selection/65714/8 "2023-11-27T21:36:18Z")

</div>

The Radio Group component enforces logic on the user through the UI; specifically, that one option - _and only one option_ - from among a list may be selected at a time. Users may therefore not select more than one option, nor may they remove the active selection.

If your use case is such that a user may select more than one option, or that a user may clear the active selection, then it is highly recommended you use Checkboxes and manage the selection logic (if any exists for your use-case) yourself.

Attempts to manipulate the active selection by using scripts to write to the index property are expected to reflect a change in selection to the front-end user by changing the selection Radio button. Scripts which write to an index which is not present are not supported, and are almost guaranteed to no longer work in the event that behavior is identified as a bug.

---

<div class="post-metadata">

**Author:** ![hw79](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@hw79](https://forum.inductiveautomation.com/u/hw79)\
**Post date:** [November 27, 2023, 9:50pm UTC](https://forum.inductiveautomation.com/t/unselect-clear-radio-group-selection/65714/9 "2023-11-27T21:50:22Z")

</div>

My train of thought was for the interaction to be similar to that of a survey where you're only allowed to select one option (less than satisfied/satisfied/more than satisfied) but you don't want anything selected when the user first encounters it.

Is there a best practice to emulate that behavior with the radio group?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [November 27, 2023, 9:57pm UTC](https://forum.inductiveautomation.com/t/unselect-clear-radio-group-selection/65714/10 "2023-11-27T21:57:06Z")

</div>

> [@hw79](#):
>
> Is there a best practice to emulate that behavior with the radio group?

Yeah, use check boxes. Nothing to stop you from making them "appear" like a radio group.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [November 28, 2023, 3:45am UTC](https://forum.inductiveautomation.com/t/unselect-clear-radio-group-selection/65714/11 "2023-11-28T03:45:54Z")

</div>

> [@hw79](#):
>
> but you don't want anything selected when the user first encounters it.

It sounds like you DO want an option selected, a la N/A.

![Screenshot 2023-11-27 at 7.45.35 PM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/6/26cd2d6cbc4f23468c6ff0bd17ca0a48b962ab49.png)
