1.2.2 • Published 3 years ago

react-confirm-pro v1.2.2

Weekly downloads
25
License
MIT
Repository
github
Last release
3 years ago

react-confirm-pro

Dialog callable component for React Live demo|Examples

Maintenance Status npm version npm downloads Build Status

Getting started

Install with NPM:

$ npm install react-confirm-pro --save

Install with Yarn:

$ yarn add react-confirm-pro

Options

AttributeTypeDefaultDescription
durationnumber0.4Animation duration.
delaynumber0.2Animation body delay
animate{in?: string;out?: string;}{in: "animate_fadeIn",out: "animate_fadeOut"}For using custom in/out animation read the guide on Animate.cssin: on Enter animationout: on Leave animation
classNamestring-Container className
onClickOutside() => void-Outside handler
closeOnClickOutsidebooleantrueOutside check
keyboardEvents{escape?: boolean;submit?: boolean;}{escape: true;submit: false}Keyboard events
customUI({onClose?: () => void;onCancel: () => void;onSubmit: () => void; }) => React.ReactNode;-Custom Ui component
bodyReact.ReactNode[]-Body content components
buttons({onClose?: () => void;onCancel: () => void;onSubmit: () => void;}) => React.ReactNode[];-Action buttons
titlestringReact.ReactNode-Component title
descriptionstringReact.ReactNode-Component description
onSubmit() => void;-Submit action
onCancel() => void;-Cancel action
closeButtonReact.ReactNode-Close icon
typelightdarklightStyle type
btnCancelstringCancelCancel button label
btnSubmitstringSubmitSubmit button label

Code examples

Other examples

Default example:

import React from 'react';
import ReactDOM from 'react-dom'
import { onConfirm } from 'react-confirm-pro';

function ReactConfirmProDemo() {
  const onClickLight = () => {
    onConfirm({
      title: (
        <h3>
          Are you sure?
        </h3>
      ),
      description: (
        <p>Do you really want to delete this records? This process cannot be undone.</p>
      ),
      onSubmit: () => {
        alert("Submit")
      },
      onCancel: () => {
        alert("Cancel")
      },
    })
  };
  return (
    <button type="button" onClick={onClick}>Click</button>
  );
}

const rootEl = document.getElementById('root')
ReactDOM.render(<ReactConfirmProDemo />, rootEl)

Custom UI:

import React from 'react';
import ReactDOM from 'react-dom'
import { onConfirm } from 'react-confirm-pro';

const CustomUI = ({
  onSubmit,
  onCancel
}) => (
  <div className="custom-ui">
    <h3>Are you sure?</h3>
    <p>Do you really want to delete this records? This process cannot be undone.</p>
    <div>
      <button onClick={onSubmit}>Yes</button>
      <button onClick={onCancel}>No</button>
    </div>
  </div>
)

function ReactCustomUIDemo() {
  const onClick = () => {
    onConfirm({
      onSubmit: () => {
        alert("Submit")
      },
      onCancel: () => {
        alert("Cancel")
      },
      customUI: CustomUI,
      className: "my-custom-ui-container"
    })
  };
  return (
	  <button onClick={onClick}>Click</button>
  );
}

const rootEl = document.getElementById('root')
ReactDOM.render(<ReactConfirmProDemo />, rootEl)