ReactJS Blueprint Introduction
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:
Similar Reads
JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav
11 min read
Web Development Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De
5 min read
React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications
15+ min read
React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version
7 min read
JavaScript Interview Questions and Answers JavaScript is the most used programming language for developing websites, web servers, mobile applications, and many other platforms. In Both Front-end and Back-end Interviews, JavaScript was asked, and its difficulty depends upon the on your profile and company. Here, we compiled 70+ JS Interview q
15+ min read
Domain Name System (DNS) DNS is a hierarchical and distributed naming system that translates domain names into IP addresses. When you type a domain name like www.geeksforgeeks.org into your browser, DNS ensures that the request reaches the correct server by resolving the domain to its corresponding IP address.Without DNS, w
8 min read
HTML Interview Questions and Answers HTML (HyperText Markup Language) is the foundational language for creating web pages and web applications. Whether you're a fresher or an experienced professional, preparing for an HTML interview requires a solid understanding of both basic and advanced concepts. Below is a curated list of 50+ HTML
14 min read
NodeJS Interview Questions and Answers NodeJS is one of the most popular runtime environments, known for its efficiency, scalability, and ability to handle asynchronous operations. It is built on Chromeâs V8 JavaScript engine for executing JavaScript code outside of a browser. It is extensively used by top companies such as LinkedIn, Net
15+ min read
Web Development Technologies Web development refers to building, creating, and maintaining websites. It includes aspects such as web design, web publishing, web programming, and database management. It is the creation of an application that works over the internet, i.e., websites.To better understand the foundation of web devel
7 min read
CSS Tutorial CSS stands for Cascading Style Sheets. It is a stylesheet language used to style and enhance website presentation. CSS is one of the three main components of a webpage, along with HTML and JavaScript.HTML adds Structure to a web page.JavaScript adds logic to it and CSS makes it visually appealing or
7 min read