Skip to content
Related Articles

Related Articles

ReactJS Blueprint Dialog Component

View Discussion
Improve Article
Save Article
  • Last Updated : 08 Apr, 2022

BlueprintJS is a React-based UI toolkit for the web. This library is very optimized and popular for building interfaces that are complex data-dense for desktop applications.

Dialog Component allows the user to show content on top of an overlay that requires user interaction. We can use the following approach in ReactJS to use the Blueprint Dialog Component.

Dialog Props:

  • autoFocus: It is used to indicate whether the overlay should acquire application focus when it first opens.
  • backdropClassName: It is used to denote the CSS class names to apply to the backdrop element.
  • backdropProps: It is used to denote the HTML props for the backdrop element.
  • canEscapeKeyClose: It is used to indicate whether pressing the ESC key should invoke onClose.
  • canOutsideClickClose: It is used to indicate whether clicking outside overlay element should invoke onClose.
  • className: It is used to denote a space-delimited list of class names to pass along to a child element.
  • enforceFocus: It is used to indicate whether the overlay should prevent focus from leaving itself.
  • icon: It is used to denote the name of an icon or an icon element to render in the dialog’s header.
  • isCloseButtonShow: It is used to indicate whether to show the close button in the dialog’s header or not.
  • isOpen: It is used to toggle the visibility of the overlay and its children.
  • lazy: The Portal containing the children is created and attached to the DOM when the overlay is opened for the first time when this is set to true and usePortal is true.
  • onClose: It is a callback that is triggered when user interaction causes the overlay to close.
  • onClosed: It is used to denote a lifecycle method invoked just after the CSS close transition ends but before the child has been removed from the DOM.
  • onClosing: It is used to denote a lifecycle method invoked just before CSS close transition begins on a child.
  • onOpened: It is used to denote a lifecycle method invoked just after the CSS open transition ends.
  • onOpening: It is used to denote a lifecycle method invoked just after mounting the child in the DOM but just before the CSS open transition begins.
  • portalClassName: It is used to denote a space-delimited string of class names applied to the Portal element if usePortal is true.
  • portalContainer: It is used to denote the container element into which the overlay renders its contents when usePortal is true.
  • style: It is used to denote the CSS styles to apply to the dialog.
  • title: It is used to denote the title of the dialog.
  • transitionDuration: It is used to indicate how long the overlay appears/disappears transition takes in milliseconds.
  • transitionName: It is used to denote the name of the transition for internal CSSTransition.
  • usePortal: It is used to indicate whether the overlay should be rendered inside a Portal attached to portalContainer prop.

MultistepDialog Props:

  • autoFocus: It is used to indicate whether the overlay should acquire application focus when it first opens.
  • backButtonProps: It is used to denote the props for the back button.
  • backdropClassName: It is used to denote the CSS class names to apply to the backdrop element.
  • backdropProps: It is used to denote the HTML props for the backdrop element.
  • canEscapeKeyClose: It is used to indicate whether pressing the ESC key should invoke onClose.
  • canOutsideClickClose: It is used to indicate whether clicking outside overlay element should invoke onClose.
  • className: It is used to denote a space-delimited list of class names to pass along to a child element.
  • enforceFocus: It is used to indicate whether the overlay should prevent focus from leaving itself.
  • finalButtonProps: It is used to denote the props for the button to display on the final step.
  • icon: It is used to denote the name of an icon or an icon element to render in the dialog’s header.
  • initialStepIndex: It is used to denote the initial step-index.
  • isCloseButtonShow: It is used to indicate whether to show the close button in the dialog’s header or not.
  • isOpen: It is used to toggle the visibility of the overlay and its children.
  • lazy: The Portal containing the children is created and attached to the DOM when the overlay is opened for the first time when this is set to true and usePortal is true.
  • nextButtonProps: It is used to denote the props for the next button.
  • onChange: It is a callback function that is triggered when the user selects a different step by clicking on back, next, or a step itself.
  • onClose: It is a callback that is triggered when user interaction causes the overlay to close.
  • onClosed: It is used to denote a lifecycle method invoked just after the CSS close transition ends but before the child has been removed from the DOM.
  • onClosing: It is used to denote a lifecycle method invoked just before CSS close transition begins on a child.
  • onOpened: It is used to denote a lifecycle method invoked just after the CSS open transition ends.
  • onOpening: It is used to denote a lifecycle method invoked just after mounting the child in the DOM but just before the CSS open transition begins.
  • portalClassName: It is used to denote a space-delimited string of class names applied to the Portal element if usePortal is true.
  • portalContainer: It is used to denote the container element into which the overlay renders its contents when usePortal is true.
  • resetOnClose: It is used to indicate whether to reset the dialog state to its initial state on close or not.
  • style: It is used to denote the CSS styles to apply to the dialog.
  • title: It is used to denote the title of the dialog.
  • transitionDuration: It is used to indicate how long the overlay appears/disappears transition takes in milliseconds.
  • transitionName: It is used to denote the name of the transition for internal CSSTransition.
  • usePortal: It is used to indicate whether the overlay should be rendered inside a Portal attached to portalContainer prop.

 

DialogStep Props:

  • backButtonProps: It is used to denote the props for the back button.
  • className: It is used to denote a space-delimited list of class names to pass along to a child element.
  • id: It is used to denote the unique identifier used to identify which step is selected.
  • nextButtonProps: It is used to denote the props for the next button.
  • panel: It is used to denote the panel content.
  • panelClassName: It is used to denote the space-delimited string of class names that are applied to multistep dialog panel container.
  • title: It is used to denote the content of step title element, rendered in a list left of the active panel.

Creating React Application And Installing Module:

  • Step 1: Create a React application using the following command:

    npx create-react-app foldername
  • Step 2: After creating your project folder i.e. foldername, move to it using the following command:

    cd foldername

  • Step 3: After creating the ReactJS application, Install the required module using the following command:

    npm install @blueprintjs/core

Project Structure: It will look like the following.

Project Structure

Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.

App.js




import React from 'react'
import '@blueprintjs/core/lib/css/blueprint.css';
import { Dialog, Classes } from "@blueprintjs/core";
  
function App() {
  
    return (
        <div style={{
            display: 'block', width: 400, padding: 30
        }}>
            <h4>ReactJS Blueprint Dialog Component</h4>
            <Dialog
                title="Dialog Title"
                icon="info-sign"
                isOpen={true}
            >
                <div className={Classes.DIALOG_BODY}>
                    <p>
                        Sample Dialog Content to display!
                    </p>
  
                </div>
            </Dialog>
        </div>
    );
}
  
export default App;

Step to Run Application: Run the application using the following command from the root directory of the project:

npm start

Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

Reference: https://blueprintjs.com/docs/#core/components/dialog


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!