Radio Button Selection in React

Viewed 53

I have successfully selected a radio button. My problem is I want to include the selection with the label also. The labels/words should be clickable also.

Here's my codesandbox CLICK HERE

 <RadioButton
    label="Food"
    name="radio"
    value="optionA"
    checked={select === "optionA"}
    handleChange={(event) => handleSelectChange(event)}
  />
  <RadioButton
    label="Water"
    name="radio"
    value="optionB"
    checked={select === "optionB"}
    handleChange={(event) => handleSelectChange(event)}
  />
2 Answers

just include the radio button inside <label> tag

   <label>
   <RadioButton
        label="Food"
        name="radio"
        value="optionA"
        checked={select === "optionA"}
        handleChange={(event) => handleSelectChange(event)}
      />
   </label>
      <label>
      <RadioButton
        label="Water"
        name="radio"
        value="optionB"
        checked={select === "optionB"}
        handleChange={(event) => handleSelectChange(event)}
      />
      </label>

Related