Giter Site home page Giter Site logo

ajclaasen / react-bootstrap-confirmation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nicolas-van/react-bootstrap-confirmation

0.0 1.0 0.0 3.47 MB

A library to easily display alerts and confirmations using React and Bootstrap

Home Page: https://nicolas-van.github.io/react-bootstrap-confirmation/

License: MIT License

JavaScript 100.00%

react-bootstrap-confirmation's Introduction

react-bootstrap-confirmation

npm version

A library to easily display alerts and confirmations using React and Bootstrap. With react-bootstrap-confirmation displaying an alert or a confirmation dialog is just as easy as calling a function:

import {alert} from 'react-bootstrap-confirmation';

alert('Something very wrong happened!');

See the demo here.

Installation

npm install --save react-bootstrap-confirmation

Usage

alert(message[, options])

An asynchronous function that will return once the alert has been dismissed.

Example

import React, {useState} from 'react';
import {alert} from 'react-bootstrap-confirmation';

const AlertButton = () => {
  const display = async () => {
    await alert('Something very wrong is happening!');
    console.log('The alert has finished displaying');
  };
  return (
    <button type="button" className="btn btn-primary" onClick={display}>
      Display alert
    </button>
  );
};

Options

Parameter name Type Description Default
title string A facultative title to use for the modal. undefined
okText string The text of the "OK" button "OK"
okButtonStyle string The style of the "OK" button. Must correspond to one of the 6 button styles of Bootstrap. "primary"

confirm(message[, options])

An asynchronous function that will return true if the user clicks the "OK" button and false in the other cases.

Example

import React, {useState} from 'react';
import {confirm} from 'react-bootstrap-confirmation';

const ConfirmButton = () => {
  const display = async () => {
    const result = await alert('Are you really sure?');
    console.log('True if confirmed, false otherwise:', result);
  };
  return (
    <button type="button" className="btn btn-primary" onClick={display}>
      Display alert
    </button>
  );
};

Options

Parameter name Type Description Default
title string A facultative title to use for the modal. undefined
okText string The text of the "OK" button "OK"
okButtonStyle string The style of the "OK" button. Must correspond to one of the 6 button styles of Bootstrap. "primary"
cancelText string The text of the "Cancel" button "Cancel"
cancelButtonStyle string The style of the "Cancel" button. Must correspond to one of the 6 button styles of Bootstrap. "secondary"

react-bootstrap-confirmation's People

Contributors

nicolas-van avatar dependabot[bot] avatar mprytoluk avatar ajclaasen avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.