Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

315
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda