Open In App

React.js Blueprint Variables Dark Theme Styles

In this article, we will learn about the Dark Theme Style 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.

Dark Theme Style Variables: These variables are used to build custom UI components that should look similar to dark-themed BlueprintJS components.



Dark Theme Style Variables:

$pt-dark-dialog-box-shadow: 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-input-box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2),
  inset 0 -1px 1px 0 #8f99a8
$pt-dark-popover-box-shadow: 0 0 0 1px #5e6064,
  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-tooltip-box-shadow: 0 2px 4px rgba(17, 20, 24, 0.4),
  0 8px 24px 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 Dark Theme Style Variables 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.

Filename: 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 Dark Theme Style Variables:
                </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>
        </div>
    );
}

Create a new file, App.scss, and assign different dark-themed style variables to different boxes.

Filename: 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-dialog-box-shadow;
}
  
.box-2 {
    box-shadow: $pt-dark-input-box-shadow;
}
  
.box-3 {
    box-shadow: $pt-dark-popover-box-shadow;
}
  
.box-4 {
    box-shadow: $pt-dark-tooltip-box-shadow;
}

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 dark-themed style variables with different shapes of boxes.

Filename: 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 Dark Theme Style Variables:
                </strong>
                <br />
                <br />
            </div>
            <div className="container">
                <div className="box-1"></div>
                <div className="box-2"></div>
                <div className="box-3"></div>
                <div className="box-4"></div>
            </div>
        </div>
    );
}

Create a new file, App.scss, and assign different dark-themed style variables to different-shaped boxes.

Filename: App.scss




@import "@blueprintjs/core/lib/scss/variables";
  
.container {
    display: flex;
    margin: 0 auto;
    justify-content: center;
    gap: 10px;
}
  
.box-1 {
    width: 100px;
    height: 100px;
    background: red;
    box-shadow: $pt-dark-dialog-box-shadow;
}
  
.box-2 {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: red;
    box-shadow: $pt-dark-input-box-shadow;
}
  
.box-3 {
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-bottom: 100px solid red;
    box-shadow: $pt-dark-popover-box-shadow;
}
  
.box-4 {
    width: 100px;
    height: 100px;
    border-radius: 100px / 50%;
    background: red;
    box-shadow: $pt-dark-tooltip-box-shadow;
}

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.dark-theme-styles


Article Tags :