Socket
Socket
Sign inDemoInstall

modalsrp14

Package Overview
Dependencies
84
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    modalsrp14

validation message for form


Version published
Maintainers
1
Created

Readme

Source

modalsrp14

simple react modal

NPM JavaScript Style Guide

Install

npm install --save modalsrp14

or

yarn add modalsrp14

Prerequisites

npm install
yarn add react react-dom
yarn add styled-components

Usage

import React, { useState } from 'react'
import Modal from 'modalsrp14'

const Form = () => {
  // write the logic for the display of the modal
  const [isShowing, setIsShowing] = useState(false)

  // write the function for close the modal
  const handleClickToClose = () => {
    setIsShowing(!isShowing)
  }

  // define the css in an object to customize the modal
  const myStylesModal = {
    modalContainerBg: 'rgba(0, 0, 0, 0.7)',
    bg: '#fff',
    width: '200px',
    height: '200px',
    radius: '5px',
    messageColor: '#000',
    messageFontSize: '1em',
    buttonColor: '#000',
    buttonBg: '#fff',
    buttonWidth: '30px',
    buttonHeight: '30px',
    buttonHoverColor: '#fff',
    buttonHoverBg: '#000'
  }

  /* then, add props in the modal component:
modalStyle = css style,
onClick = modal closing function,
messageText = the message to display */
  return (
    <>
      <form>.... </form>
      {isShowing ? (
        <>
          <Modal
            modalStyles={myStylesModal}
            onClick={handleClickToClose}
            messageText='Employee created !'
          />
        </>
      ) : null}
    </>
  )
}

FAQs

Last updated on 03 Jul 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc