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

116
Vistas
Materialiui Paper api with close button

I am implementing Paper from Material UI: https://mui.com/components/paper/

And here is the code I have written so far:

<Paper className="modal" elevation={3}>
    {..Content..}
</Paper>

The current UI makes it open a special pane which closes only when I click on area outside of it. I want to add a close button to close the Paper. Is it possible to add a custom onClose action on it?

Edit: Here is a codesandbox that I have replicated: https://codesandbox.io/s/black-surf-r1yz87?file=/src/App.js

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Paper is just a surface to render components on, it does not support any functionality. For this use case, a state variable can be used to hide and unhide the Paper component. You may make it a reusable component.

const [shouldShowPaper, setShouldShowPaper] = useState(true);
 ...
{
    shouldShowPaper && 
    <Paper elevation={props.elevation} style={{position: "relative"}}>
        <button 
            style={{position:"absolute", top: "10px", right: "10px"}}
            onClick={() => setShouldShowPaper(false)}
        >
            X
        </button>
        {props.children}
    </Paper>
}

You may toggle classes to show transitions instead of abrupt removal of the paper component.

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