content logo

React Popups:

React Glassy Gradient Popup Modal

If you need a pop-up using React and your website theme is dark and gray, this pop-up will be useful for you. There is a purple button on the page that opens by clicking on the pop-up. The pop-up we have in this code has a gray theme. This pop-up has curved corners. The background of this pop-up is gradient. To close the pop-up, you can click on the red button inside the pop-up.

#

Glassy CSS Popup

#

HTML Gradient Popup

#

React JS Popup Code

#

Simple React Popup Modal

<!-- This script got from frontendfreecode.com -->
<div id="root"></div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300&display=swap');
* {
  margin: 0;
  padding: 0;
  font-family: 'Roboto Mono';
}
html, body {
  height: 100%;
}
body {
  background: linear-gradient(
    to right top,
    rgb(51, 51, 51),
    rgb(30, 30, 30)
  );
}
.center {
  position: fixed;
  top: 0;
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  background: linear-gradient(
    to bottom right,
    rgba(255, 255, 255, 0.2),
    rgba(255, 255, 255, 0.5)
  );
  backdrop-filter: blur(2px);
}
.modal-content {
  background: linear-gradient(
    to top right,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.5)
  );
  width: 350px;
  height: 250px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 20px;
  border: solid 1px #bbb;
  border-radius: 15px;
  backdrop-filter(blur(2px))
  text-align: center;
}
h1 {
  text-align: center;
  word-break: break-word;
  color: #111;
  font-size: 30px;
  margin-bottom: 4px;
}
p {
  text-align: center;
  word-break: break-word;
  color: #111;
  font-size: 20px;
  margin-bottom: 15px;
}
.visibility-false {
  display: none;
}
.button {
  border: none;
  width: 140px;
  height: 70px;
  border-radius: 15px;
  cursor: pointer;
  font-size: 15px;
  background: linear-gradient(
    to bottom right,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.5)
  );
  color: white;
}
.close-button {
  background-color: red;
}
.open-button {
  background-color: rebeccapurple;
  margin: 20px;
}
function Modal({ children, isOpen }) {
  return /*#__PURE__*/(
    React.createElement("div", { className: `visibility-${isOpen} center` },
    children));
}
function App() {
  const [modalVisibility, setModalVisibility] = React.useState(false);
  function handleOpenModalClick() {
    setModalVisibility(true);
  }
  function handleCloseModalClick() {
    setModalVisibility(false);
  }
  return /*#__PURE__*/(
    React.createElement(React.Fragment, null, /*#__PURE__*/
    React.createElement("button", {
      onClick: handleOpenModalClick,
      className: 'button open-button' }, "Open Modal"), /*#__PURE__*/
    React.createElement(Modal, { isOpen: modalVisibility }, /*#__PURE__*/
    React.createElement("div", { className: 'modal-content' }, /*#__PURE__*/
    React.createElement("h1", null, "Hello, World!"), /*#__PURE__*/
    React.createElement("p", null, "This is a Modal!"), /*#__PURE__*/
    React.createElement("button", {
      onClick: handleCloseModalClick,
      className: 'button close-button' }, "Close Modal")))));
}
function Index() {
  return /*#__PURE__*/(
    React.createElement(App, null));
}
ReactDOM.render( /*#__PURE__*/React.createElement(Index, null), document.querySelector('#root'));
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/17.0.1/umd/react.production.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.1/umd/react-dom.production.min.js'></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<script src='https://cdnjs.cloudflare.com/ajax/libs/react/17.0.1/umd/react.production.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.1/umd/react-dom.production.min.js'></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300&display=swap');
* {
  margin: 0;
  padding: 0;
  font-family: 'Roboto Mono';
}
html, body {
  height: 100%;
}
body {
  background: linear-gradient(
    to right top,
    rgb(51, 51, 51),
    rgb(30, 30, 30)
  );
}
.center {
  position: fixed;
  top: 0;
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  background: linear-gradient(
    to bottom right,
    rgba(255, 255, 255, 0.2),
    rgba(255, 255, 255, 0.5)
  );
  backdrop-filter: blur(2px);
}
.modal-content {
  background: linear-gradient(
    to top right,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.5)
  );
  width: 350px;
  height: 250px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 20px;
  border: solid 1px #bbb;
  border-radius: 15px;
  backdrop-filter(blur(2px))
  text-align: center;
}
h1 {
  text-align: center;
  word-break: break-word;
  color: #111;
  font-size: 30px;
  margin-bottom: 4px;
}
p {
  text-align: center;
  word-break: break-word;
  color: #111;
  font-size: 20px;
  margin-bottom: 15px;
}
.visibility-false {
  display: none;
}
.button {
  border: none;
  width: 140px;
  height: 70px;
  border-radius: 15px;
  cursor: pointer;
  font-size: 15px;
  background: linear-gradient(
    to bottom right,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.5)
  );
  color: white;
}
.close-button {
  background-color: red;
}
.open-button {
  background-color: rebeccapurple;
  margin: 20px;
}
</style>

</head>
<body>
<div id="root"></div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
function Modal({ children, isOpen }) {
  return /*#__PURE__*/(
    React.createElement("div", { className: `visibility-${isOpen} center` },
    children));
}
function App() {
  const [modalVisibility, setModalVisibility] = React.useState(false);
  function handleOpenModalClick() {
    setModalVisibility(true);
  }
  function handleCloseModalClick() {
    setModalVisibility(false);
  }
  return /*#__PURE__*/(
    React.createElement(React.Fragment, null, /*#__PURE__*/
    React.createElement("button", {
      onClick: handleOpenModalClick,
      className: 'button open-button' }, "Open Modal"), /*#__PURE__*/
    React.createElement(Modal, { isOpen: modalVisibility }, /*#__PURE__*/
    React.createElement("div", { className: 'modal-content' }, /*#__PURE__*/
    React.createElement("h1", null, "Hello, World!"), /*#__PURE__*/
    React.createElement("p", null, "This is a Modal!"), /*#__PURE__*/
    React.createElement("button", {
      onClick: handleCloseModalClick,
      className: 'button close-button' }, "Close Modal")))));
}
function Index() {
  return /*#__PURE__*/(
    React.createElement(App, null));
}
ReactDOM.render( /*#__PURE__*/React.createElement(Index, null), document.querySelector('#root'));
</script>

</body>
</html>
Preview