3.0.6 • Published 3 years ago

react-confirm-alert v3.0.6

Weekly downloads
28,665
License
MIT
Repository
github
Last release
3 years ago

react-confirm-alert

React 18 is supported!!

For React <= 17.x.x use version 2.x.x

React component confirm dialog. Live demo

npm version

Document for v.1.x.x, v.2.x.x

Getting started

Install with NPM:

$ npm install react-confirm-alert --save

Options

const options = {
  title: 'Title',
  message: 'Message',
  buttons: [
    {
      label: 'Yes',
      onClick: () => alert('Click Yes')
    },
    {
      label: 'No',
      onClick: () => alert('Click No')
    }
  ],
  closeOnEscape: true,
  closeOnClickOutside: true,
  keyCodeForClose: [8, 32],
  willUnmount: () => {},
  afterClose: () => {},
  onClickOutside: () => {},
  onKeypress: () => {},
  onKeypressEscape: () => {},
  overlayClassName: "overlay-custom-class-name"
};

confirmAlert(options);

Use with function:

import { confirmAlert } from 'react-confirm-alert'; // Import
import 'react-confirm-alert/src/react-confirm-alert.css'; // Import css

class App extends React.Component {
  submit = () => {
    confirmAlert({
      title: 'Confirm to submit',
      message: 'Are you sure to do this.',
      buttons: [
        {
          label: 'Yes',
          onClick: () => alert('Click Yes')
        },
        {
          label: 'No',
          onClick: () => alert('Click No')
        }
      ]
    });
  };

  render() {
    return (
      <div className='container'>
        <button onClick={this.submit}>Confirm dialog</button>
      </div>
    );
  }
}

Custom UI Component

confirmAlert({
  customUI: ({ onClose }) => {
    return (
      <div className='custom-ui'>
        <h1>Are you sure?</h1>
        <p>You want to delete this file?</p>
        <button onClick={onClose}>No</button>
        <button
          onClick={() => {
            this.handleClickDelete();
            onClose();
          }}
        >
          Yes, Delete it!
        </button>
      </div>
    );
  }
});
qista@fishbot/ui@paul_kratz/hc-componentsvoucher_1max-voucher-react@infinitebrahmanuniverse/nolb-react-con@everything-registry/sub-chunk-2547ws-voice-infinity-global-modulews-intranet-global-modulews-react-base-componentsthistylvishvamvexamla-floweritatradehood-apptripkit-react@airjam/react-calendar-resource-editor@adminator/chromista@baby-garage/shared@bigbroindia/helper@capytale/activity.ui@ccreator/smart-ui@chainge/plugin@chargedcloud/react-crudgenerator@4alldigital/foundation-ui--gamma@hadmean/chromista@muhammadz/elixir-react-native-components@meshify/core@meshify/modal@jackcmeyer/components@quillforms/block-editor@quillforms/builder-core@quillforms/notifications-editor@satellite-healthcare/shc-react-web-components@reglendo/mergado-ui-kit@riversilica_narendra/webapp@riversilica_narendra/react-confirm-alert-2.8.0@romger/react-base-components@shashank8317/webapp-projectonworktestseedbox-downloaderreact-card-shoppingreact-chats-appreact-chatters-firstreact-chat-unlimitedreact-chameleon-uireact-chat-fivereact-chat-sevenreact-chat-sixreact-chat-testreact-crudgeneratorreact-frontend-chatreact-fs-treeviewsawalareact-input-kitinreactroopneomapnibi.ai.nlqpnh-assessment-livecollab-featurepnh-assessment-livecollab-latestfeaturepnh-live-code-editor-finalpnh-live-package-end-phase2pnh-live-package-end-phase3pnh-live-package-end-phase4red-metrics-2-frontendrap-react-baserap-react-base2rap-reactreact-quill-securitysoap-box-1.0.1shu-ui-libreact-v2react-ui-chameleon@windastella/uikitcra-template-code4-cardscustomer-immersioncards-template-code4energy-microfrontende-brokerexalt3d-sublime-uihadmeanioexplorer-componentslive-collab-testing-1live-collab-testing-2live-collab-testing-3live-collab-testing-4live-collab-testing-5loanfront-ui-componentsloanfront-ui-testingloanfront-booster-s5@thewhite/react-attachments@thewhite/react-base-components@thewhite/react-geobasket_deskfranchisee-mgmtformik-generator
3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.0

3 years ago

2.8.0

3 years ago

2.7.0

4 years ago

2.6.2

5 years ago

2.6.1

5 years ago

2.6.0

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.4.1

6 years ago

2.4.0

6 years ago

2.3.0

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.7

6 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago