Need help with fixing radiobuttion selection. In the image, you can see all buttons selected but only one button should be selected and others should be deselected automatically. with Standard HTML Input type radio, it works fine. But I want to try with Lightning Input radio button
How to select lightning radio input in such a way that it deselects the other radiobuttons automatically
htmljavascriptlightning-web-components
Best Answer
You need to specify a
name
andvalue
, just as you would in normal HTML.This will allow you to get the radio behavior, as well as tell which item is selected.
Note that the
name
must be the same for alltype="radio"
that should behave as a single radio selection, which is why I used item.id as the unique name. You can derive another name if you desire, just make sure they are unique on the page.Demo.