3.0.6 • Published 2 years ago

react-confirm-alert v3.0.6

Weekly downloads
28,665
License
MIT
Repository
github
Last release
2 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-2547react-input-kitinreact-ui-chameleonreact-fs-treeviewreact-frontend-chatreactroopred-metrics-2-frontendreact-v2sawalatradehood-appseedbox-downloadershu-ui-libthistylreact-quill-securityvexamvishvamtripkit-reactws-intranet-global-modulews-react-base-componentsws-voice-infinity-global-moduleexalt3d-sublime-uifranchisee-mgmtformik-generator@meshify/core@meshify/modal@muhammadz/elixir-react-native-components@reglendo/mergado-ui-kit@riversilica_narendra/react-confirm-alert-2.8.0@riversilica_narendra/webapp@romger/react-base-componentsioexplorer-components@hadmean/chromistae-brokerenergy-microfrontend@jackcmeyer/components@quillforms/builder-core@quillforms/notifications-editor@quillforms/block-editorhadmean@satellite-healthcare/shc-react-web-components@shashank8317/webapp-project@thewhite/react-base-components@thewhite/react-geo@bigbroindia/helperbasket_deskneomap@baby-garage/sharedloanfront-booster-s5loanfront-ui-componentsloanfront-ui-testingcards-template-code4@adminator/chromista@chainge/pluginla-flowerita@windastella/uikitlive-collab-testing-1live-collab-testing-2live-collab-testing-3live-collab-testing-4live-collab-testing-5@ccreator/smart-uinibi.ai.nlqcra-template-code4-cards@chargedcloud/react-crudgeneratorpnh-live-package-end-phase2pnh-live-package-end-phase3pnh-live-package-end-phase4customer-immersionpnh-assessment-livecollab-featurepnh-assessment-livecollab-latestfeaturepnh-live-code-editor-finaldashpressonworktestrap-reactrap-react-baserap-react-base2react-chameleon-uireact-chat-fivereact-chat-sevenreact-chat-sixreact-chat-testreact-chat-unlimitedreact-card-shoppingreact-chats-appreact-chatters-firstreact-crudgenerator
3.0.4

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.0

2 years ago

2.8.0

2 years ago

2.7.0

3 years ago

2.6.2

4 years ago

2.6.1

4 years ago

2.6.0

4 years ago

2.5.1

4 years ago

2.5.0

4 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.0

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.7

5 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago