Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

89
Views
MUI - Click link in Checkbox label

I want to make a "Terms of Use" checkbox, and I'm using FormControlLabel for nesting a Checkbox for it, but I need to make a link that when clicked is opening a Dialog component, that is rendering the terms, but when I click on the link "" it also checks the checkbox, since it's inside the label.

It's pretty hard trying to make a structure to make it look good, so it would be beneficial if it was possible to render the link inside the label as well.

Here is the code:

<FormGroup row className={localClasses.greenCheckbox}>
  <FormControlLabel
    control={
      <Checkbox
        checked={state.lgpd_agreement}
        onChange={lgpdAgreementOnChange}
        name="lgpd_agreement"
      />
    }
    label={
      <p>
        Autorizo a #### coletar e armazenar meus dados com a finalidade
        de fornecer os serviços do programa conforme o respectivo
        Termo&nbsp;
  <span className={localClasses.openDialogButton} onClick={() => handleOpenModal('authTerm')}>Ler</span>
      </p>
    }
  />
</FormGroup>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Call e.preventDefault() to cancel the current event so the Checkbox state is not updated:

<FormControlLabel
  control={<Checkbox name="lgpd_agreement" />}
  label={
    <p>
      random text
      <Link
        onClick={(e) => {
          e.preventDefault();
          alert('link clicked!');
        }}
      >
        Your Link
      </Link>
    </p>
  }
/>

Codesandbox Demo

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!