How to change border radius of mui dialog in react js?
August 26, 2023Hi Friends 👋,
Welcome To aGuideHub!
To change border radius of mui dialog actions in react js, you can set .MuiPaper-root
in border-radius: 30px;
in dialog. it will change border radius of mui dialog actions in React JS.
Today, I am going to show you, How to change border radius of mui dialog actions in react js
Installation
Install the following packages to use mui dialog in react js.
npm
npm install @mui/material @emotion/react @emotion/styled
yarn
yarn add @mui/material @emotion/react @emotion/styled
Table of contents
- Install MUI and create a new React app.
- Import Material-UI dialog.
- Use the dialog Component
Step 1: Install MUI and create a new React app.
First you have to install the React project. You should use create-react-app
command to create a new React project.
npx create-react-app my-app
cd my-app
npm start
Step 2: Import Material-UI dialog.
After installing MUI
, you have to import your React component. To do this, add the following line to the top of your component file.
import React, { useState } from "react";
import Dialog from "@mui/material/Dialog";
import DialogTitle from "@mui/material/DialogTitle";
import DialogContent from "@mui/material/DialogContent";
import DialogActions from "@mui/material/DialogActions";
import Button from "@mui/material/Button";
import "./styles.css";
Step 3: Use the dialog Component.
You can use the dialog
component in your react js. For example, A Dialog is a type of modal window that appears in front of app content to provide critical information or ask for a decision. Dialogs disable all app functionality when they appear, and remain on screen until confirmed, dismissed, or a required action has been taken. You can use <Dialog>
component make mui dialog in react js.
<Dialog open={open} onClose={onClose}>
<DialogTitle>{title}</DialogTitle>
<DialogContent dividers className="custom-dialog-content">
{content}
</DialogContent>
<DialogActions>
<Button onClick={onClose} color="primary">
Close
</Button>
</DialogActions>
</Dialog>
MUI material change border radius of mui dialog actions example.
The below code is an example, you need to import dialog
Component. Then, you can create a dialog button and you can set .MuiPaper-root
in border-radius: 30px;
component change border radius of mui dialog actions in react.
App.js
import React, { useState } from "react";
import Dialog from "@mui/material/Dialog";
import DialogTitle from "@mui/material/DialogTitle";
import DialogContent from "@mui/material/DialogContent";
import DialogActions from "@mui/material/DialogActions";
import Button from "@mui/material/Button";
import "./styles.css";
function CustomDialog({ open, onClose, title, content }) {
return (
<Dialog open={open} onClose={onClose}>
<DialogTitle>{title}</DialogTitle>
<DialogContent dividers className="custom-dialog-content">
{content}
</DialogContent>
<DialogActions>
<Button onClick={onClose} color="primary">
Close
</Button>
</DialogActions>
</Dialog>
);
}
function App() {
const [open, setOpen] = useState(false);
const handleOpen = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
};
return (
<div>
<Button variant="outlined" onClick={handleOpen}>
Open Dialog
</Button>
<CustomDialog
open={open}
onClose={handleClose}
title="Sample Dialog"
content="This is the content of the dialog."
/>
</div>
);
}
export default App;
.MuiPaper-root {
border-radius: 30px;
}
In the above code example, I have used the @mui/material
component and changed border radius of mui dialog actions in react js.
Check the output of the above code example.
Here, we are provided code sandbox links for the above program change border radius of mui dialog actions in react js. Then you can use whenever you want and do the changes as per your requirements.
All the best 👍