Open In App

React.js BluePrint Variables Elevation drop shadows

Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will learn about the Elevation Drop Shadow Variables offered by the blueprint.js library. BlueprintJS is a React-based UI toolkit for the web. It is written in Typescript. This library is very optimized and popular for building interfaces that are complex and data-dense for desktop applications that run in a modern web browser.

Elevation Drop Shadow Variables: These variables are used to apply drop shadows (box-shadows) to custom UI elements. They are available to use by the developers in the Sass or Less variables files.

Elevation Drop Shadow Variables List:

  • $pt-elevation-shadow-0: It corresponds to the following value in CSS 
$pt-elevation-shadow-0: 
    0 0 0 1px rgba(17, 20, 24, 0.15)
  • $pt-elevation-shadow-1:  It corresponds to the following value in CSS 
$pt-elevation-shadow-1: 
    0 0 0 1px rgba(17, 20, 24, 0.1),
      0 1px 1px rgba(17, 20, 24, 0.2)
  • $pt-elevation-shadow-2:  It corresponds to the following value in CSS 
$pt-elevation-shadow-2: 
    0 0 0 1px rgba(17, 20, 24, 0.1),
      0 1px 1px rgba(17, 20, 24, 0.2), 
      0 2px 6px rgba(17, 20, 24, 0.2)
  • $pt-elevation-shadow-3:  It corresponds to the following value in CSS 
$pt-elevation-shadow-3: 
    0 0 0 1px rgba(17, 20, 24, 0.1),
      0 2px 4px rgba(17, 20, 24, 0.2), 
      0 8px 24px rgba(17, 20, 24, 0.2)
  • $pt-elevation-shadow-4:  It corresponds to the following value in CSS 
$pt-elevation-shadow-4: 
    0 0 0 1px rgba(17, 20, 24, 0.1),
      0 4px 8px rgba(17, 20, 24, 0.2), 
      0 18px 46px 6px rgba(17, 20, 24, 0.2)
  • $pt-dark-elevation-shadow-0:  It corresponds to the following value in CSS 
$pt-dark-elevation-shadow-0: 
    inset 0 0 0 1px rgba(255, 255, 255, 0.2)
  • $pt-dark-elevation-shadow-1:  It corresponds to the following value in CSS 
$pt-dark-elevation-shadow-1: inset 
    0 0 0 1px rgba(255, 255, 255, 0.2),
      0 1px 1px 0 rgba(17, 20, 24, 0.4)
  • $pt-dark-elevation-shadow-2:  It corresponds to the following value in CSS 
$pt-dark-elevation-shadow-2: inset 
    0 0 0 1px rgba(255, 255, 255, 0.2),
      0 1px 1px rgba(17, 20, 24, 0.4), 
      0 2px 6px rgba(17, 20, 24, 0.4)
  • $pt-dark-elevation-shadow-3:  It corresponds to the following value in CSS 
$pt-dark-elevation-shadow-3: inset 
    0 0 0 1px rgba(255, 255, 255, 0.2),
      0 2px 4px rgba(17, 20, 24, 0.4), 
      0 8px 24px rgba(17, 20, 24, 0.4)
  • $pt-dark-elevation-shadow-4:  It corresponds to the following value in CSS 
$pt-dark-elevation-shadow-4: inset 
    0 0 0 1px rgba(255, 255, 255, 0.2),
      0 4px 8px rgba(17, 20, 24, 0.4), 
      0 18px 46px 6px rgba(17, 20, 24, 0.4)

 

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
npm install @blueprint/datetime @blueprintjs/datetime2
npm install sass

Project Structure: It will look like the following.

Example 1: The below example demonstrates the usage of different elevation drop shadows in the light theme used by BlueprintJS.

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 './App.scss'
  
export default function App() {
    return (
        <div>
            <div
                className="head"
                style={{
                    width: "fit-content",
                    margin: "auto",
                }}
            >
                <h1
                    style={{
                        color: "green",
                    }}
                >
                    GeeksforGeeks
                </h1>
                <strong>
                    React blueprint Variables Elevation 
                    Drop Shadows
                </strong>
                <br /><br />
            </div>
            <div className="container">
                <div className="box box-1"></div>
                <div className="box box-2"></div>
                <div className="box box-3"></div>
                <div className="box box-4"></div>
                <div className="box box-5"></div>
            </div>
        </div>
    );
}


Create a new file, App.scss, and assign different box-shadows to different boxes.

App.scss




@import "@blueprintjs/core/lib/scss/variables";
  
.container {
    display: flex;
    margin: 0 auto;
    justify-content: center;
    gap: 5px;
}
  
.box {
    width: 100px;
    height: 100px;
    background-color: white;
}
  
.box-1 {
    box-shadow: $pt-elevation-shadow-0;
}
  
.box-2 {
    box-shadow: $pt-elevation-shadow-1;
}
  
.box-3 {
    box-shadow: $pt-elevation-shadow-2;
}
  
.box-4 {
    box-shadow: $pt-elevation-shadow-3;
}
  
.box-5 {
    box-shadow: $pt-elevation-shadow-4;
}


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: The below example demonstrates the usage of different elevation drop shadows in the dark theme used by BlueprintJS.

App.js




import './App.scss'
import "@blueprintjs/core/lib/css/blueprint.css";
  
export default function App() {
    return (
        <div>
            <div
                className="head"
                style={{
                    width: "fit-content",
                    margin: "auto",
                }}
            >
                <h1
                    style={{
                        color: "green",
                    }}
                >
                    GeeksforGeeks
                </h1>
                <strong>
                    React blueprint Variables 
                    Grids & dimensions
                </strong>
                <br /><br />
            </div>
            <div className="container">
                <div className="box box-1"></div>
                <div className="box box-2"></div>
                <div className="box box-3"></div>
                <div className="box box-4"></div>
                <div className="box box-5"></div>
            </div>
        </div>
    );
}


Create a new file, App.scss, and assign different box-shadows to different boxes.

App.scss




@import "@blueprintjs/core/lib/scss/variables";
  
.container {
    display: flex;
    margin: 0 auto;
    justify-content: center;
    gap: 5px;
}
  
.box {
    width: 100px;
    height: 100px;
    background-color: white;
}
  
.box-1 {
    box-shadow: $pt-dark-elevation-shadow-0;
}
  
.box-2 {
    box-shadow: $pt-dark-elevation-shadow-1;
}
  
.box-3 {
    box-shadow: $pt-dark-elevation-shadow-2;
}
  
.box-4 {
    box-shadow: $pt-dark-elevation-shadow-3;
}
  
.box-5 {
    box-shadow: $pt-dark-elevation-shadow-4;
}


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

npm start

Output:

 

Reference: https://blueprintjs.com/docs/#core/variables.elevation-drop-shadows



Last Updated : 06 Oct, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads