DEV Community

elvisnguy
elvisnguy

Posted on

Checkbox Group ReactJS issue

I'm a newbie of ReactJS, I was mess around with this function. Here I'm got 3 group of checkbox so I wanna when I checked/unchecked 1st box (2nd,3rd) of group checkbox then it's same effected like this :https://www.loom.com/share/35506f4234a649a9b98213dd0430bf9e

I'm so grateful with every idea which community give me, tks you all

export const Vertical: ComponentStory<typeof EdsFormCheckbox> = () => {
  const [isChecked, setChecked] = useState({checkOne:false,checkTwo: false,checkThree: false});
  const handleClick = (e: ChangeEvent<HTMLInputElement>) => setChecked(isChecked.checkOne);
Enter fullscreen mode Exit fullscreen mode

return (


    onChange={handleClick}<br>
    name="standard"<br>
    labelText="Standard"<br>
    className="gap-300"<br>
  &gt;<br>
    <br>
    <br>
    <br>
Enter fullscreen mode Exit fullscreen mode
  <EdsCheckboxGroup
    onChange={handleClick}
    name="required"
    labelText="Required"
    className="gap-300"
  >
    <EdsFormCheckbox checked={isChecked.checkOne} labelText="Math" isRequired></EdsFormCheckbox>
    <EdsFormCheckbox checked={isChecked.checkTwo} labelText="Science" isRequired></EdsFormCheckbox>
    <EdsFormCheckbox checked={isChecked.checkThree}  labelText="English" isRequired></EdsFormCheckbox>
  </EdsCheckboxGroup>

  <EdsCheckboxGroup
    onChange={handleClick}
    name="disable"
    labelText="Disable"
    className="gap-300"
  >
    <EdsFormCheckbox checked={isChecked.checkOne} labelText="Math" isDisabled></EdsFormCheckbox>
    <EdsFormCheckbox checked={isChecked.checkTwo} labelText="Science" isDisabled></EdsFormCheckbox>
    <EdsFormCheckbox checked={isChecked.checkThree} labelText="English" isDisabled></EdsFormCheckbox>
  </EdsCheckboxGroup>

Neon image

Serverless Postgres in 300ms (!)

10 free databases with autoscaling, scale-to-zero, and read replicas. Start building without infrastructure headaches. No credit card needed.

Try for Free →

Top comments (0)

AWS Industries LIVE! Stream

Watch AWS Industries LIVE!

New tech. Real solutions. See what’s possible on Industries LIVE! with AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay