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

314
Views
ReactJS: clickable text - how can I disable click outside the text area?

I have a clickable text component with Material UI Typography:

            <MDBox mt={2} mb={1}>              
              <MDTypography variant="body2" style={{color: 'white', cursor:"pointer"}}
                onClick={()=>dispatch({type: "goBackToPage1"})}
              >
                Go back to previous page
              </MDTypography>
            </MDBox>

enter image description here

As you can see, the Typography takes up the entire row area, such that even if I put the mouse on the green area (on the same row but outside the text area), the mouse still turns into a pointer and you can still click it.

enter image description here

How do I restrict clicking to be strictly on the text, instead the whole row area?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can try to pass "component" prop to MUI Typography and and set it as span

<Typography component="span">
  ...
</Typography>
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!