Wednesday, November 20, 2024
Google search engine
HomeLanguagesReact.js Blueprint Variables Color Aliases

React.js Blueprint Variables Color Aliases

In this article, we will learn about the Color Aliases 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.

Variables Color Aliases: These variables are semantic aliases of the colors used by the BlueprintJS library to maintain consistency in the color usages among different internal components. They are available to use by the developers in the Sass or Less variables files.

Color aliases:

  • $pt-intent-primary: It denotes the primary intent color.
  • $pt-intent-success: It denotes the success intent color.
  • $pt-intent-warning: It denotes the warning intent color.
  • $pt-intent-danger: It denotes the danger intent color.
  • $pt-app-background-color: It denotes the application background color.
  • $pt-dark-app-background-color: It denotes the dark theme application background color.
  • $pt-text-color: It denotes the default text color.
  • $pt-text-color-muted: It denotes the muted text color.
  • $pt-text-color-disabled: It denotes the disabled text color.
  • $pt-heading-color: It denotes the headers’ text color.
  • $pt-link-color: It denotes the links’ text color.
  • $pt-dark-text-color: It denotes the dark theme default text color.
  • $pt-dark-text-color-muted: It denotes the dark theme muted text color.
  • $pt-dark-text-color-disabled: It denotes the dark theme disabled text color.
  • $pt-dark-heading-color: It denotes the dark theme text color for headers.
  • $pt-dark-link-color: It denotes the dark theme text color for links.
  • $pt-text-selection-color: It denotes the text selection color.
  • $pt-icon-color: It denotes the default icon color.
  • $pt-icon-color-hover: It denotes the hovered icon color.
  • $pt-icon-color-disabled: It denotes the disabled icon color.
  • $pt-icon-color-selected: It denotes the selected icon color.
  • $pt-dark-icon-color: It denotes the dark theme default icon color.
  • $pt-dark-icon-color-hover: It denotes the dark theme hovered icon color.
  • $pt-dark-icon-color-disabled: It denotes the dark theme disabled icon color.
  • $pt-dark-icon-color-selected: It denotes the dark theme selected icon color.
  • $pt-divider-black: It denotes the primary intent color.
  • $pt-dark-divider-black: It denotes the black divider color.
  • $pt-dark-divider-white: It denotes the dark theme black divider color.
  • $pt-code-text-color: It denotes the code text color.
  • $pt-code-background-color: It denotes the code background color.
  • $pt-dark-code-text-color: It denotes the dark theme code text color.
  • $pt-dark-code-background-color: It denotes the dark theme code background color.

 

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: Below example demonstrates the usage of different intent colors 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

Javascript




import './App.scss'
  
export default function App() {
    return (
        <div>
            <div
                className="head"
                style={{
                    width: "fit-content",
                    margin: "auto",
                }}
            >
                <h1
                    style={{
                        color: "green",
                    }}
                >
                    neveropen
                </h1>
                <strong>React blueprint Variables 
                    color aliases</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 intent colors to different boxes.

Filename: App.scss

CSS




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


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: Below example demonstrates the usage of different text colors used by BlueprintJS.

Filename: App.js

Javascript




import './App.scss'
  
export default function App() {
    return (
        <div>
            <div
                className="head"
                style={{
                    width: "fit-content",
                    margin: "auto",
                }}
            >
                <h1
                    style={{
                        color: "green",
                    }}
                >
                    neveropen
                </h1>
                <strong>
                    React blueprint Variables color aliases
                </strong>
                <br />
                <br />
            </div>
            <div className="container">
                <p className='p p-1'>default text color</p>
                <p className='p p-2'>muted text color</p>
                <p className='p p-3'>disabled text color</p>
            </div>
        </div>
    );
}


Create a new file, App.scss, and assign different text colors to different paragraphs.

Filename: App.scss

CSS




@import "@blueprintjs/core/lib/scss/variables";
  
.container {
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    align-items: center;
    gap: 5px;
}
  
.p-1 {
    color: $pt-text-color;
}
  
.p-2 {
    color: $pt-text-color-muted;
}
  
.p-3 {
    color: $pt-text-color-disabled;
}


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.color-aliasesIt denotes the primary intent color

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments