Skip to content
Related Articles

Related Articles

ReactJS Blueprint Introduction

Improve Article
Save Article
Like Article
  • Last Updated : 14 May, 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. This is not a mobile-first UI toolkit.

Installation: First install node.js in your machine and then install the package and its dependencies with an NPM client through npm or yarn:

npm i @blueprintjs/core
// or
yarn add @blueprintjs/core react react-dom

After installation, you’ll be able to import the React components in your application like:

import { Button } from "@blueprintjs/core";

Don’t forget to include the main CSS file from each Blueprint package, Additionally, the directory contains supporting media.

Using node-style package resolution in a CSS file: 

@import "~normalize.css";
@import "~@blueprintjs/core/lib/css/blueprint.css";
@import "~@blueprintjs/icons/lib/css/blueprint-icons.css";

or using plain old HTML

<link href=”path/to/node_modules/normalize.css/normalize.css” rel=”stylesheet” />
<link href=”path/to/node_modules/@blueprintjs/core/lib/css/blueprint.css” rel=”stylesheet” />
<link href=”path/to/node_modules/@blueprintjs/icons/lib/css/blueprint-icons.css” rel=”stylesheet” />

Blueprint components require the following ES2015 features:

  • Map
  • Set
  • Array.prototype.fill
  • Array.prototype.from
  • String.prototype.startsWith
  • Object.values

Blueprint is written in TypeScript, and it is having its own “.d.ts” file, therefore its “.d.ts” type definitions are distributed in the NPM package and should be resolved automatically by the compiler. 

However, you’ll need to install typing for Blueprint’s dependencies before you can consume it:

npm install --save @types/react @types/react-dom

Let’s understand it’s working with the help of examples.

Step 1: Create a react app appname:

npx create-react-app appname

Step 2: Change directory to app name:

cd appname

Step 3: Install the dependency:

npm i @blueprintjs/core
// or
yarn add @blueprintjs/core react react-dom

Project Structure: Now, the folder structure will look like this:

 

Example 1: In this example, we will use the menu component of Reactjs Blueprint. 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 { Menu, Classes, MenuItem, MenuDivider, 
    Icon } from "@blueprintjs/core";
  
function App() {
    return (
        <div style={{
            display: 'block', width: 400, padding: 30
        }}>
            <h4>ReactJS Blueprint Menu Component</h4>
            <Menu className={Classes.ELEVATION_1}>
                <MenuItem icon={<Icon icon="home" />} text="Home" />
                <MenuDivider />
                <MenuItem icon="new-link" text="WebLinks" />
                <MenuItem icon="user" text="Profile" />
                <MenuDivider />
                <MenuItem icon="cog" text="Setting" />
            </Menu>
        </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:

 

Example 2: In this example, we will see how to use the dialog component in Reactjs Bueprint.

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;

Output:

 


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!