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

117
Views
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 answers
Answer question

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 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!