React.js Blueprint Variables Font variables
In this article, we will learn about the Font 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.
Font Variables: These variables are used for custom styling different fonts. They are available to use by the developers in the Sass or less variables files.
Font Variables:
- $pt-font-family: It corresponds to the following value in the CSS
$pt-font-family: -apple-system, “BlinkMacSystemFont”, “Segoe UI”, “Roboto”,
“Oxygen”, “Ubuntu”, “Cantarell”, “Open Sans”, “Helvetica Neue”,
“blueprint-icons-16”, sans-serif
- $pt-font-family-monospace: It corresponds to the following value in CSS
$pt-font-family-monospace: monospace
- $pt-font-size: It corresponds to the following value in the CSS
$pt-font-size: 14px
- $pt-font-size-small: It corresponds to the following value in the CSS
$pt-font-size-small: 12px
- $pt-font-size-large: It corresponds to the following value in CSS
$pt-font-size-large: 16px
- $pt-line-height: It corresponds to the following value in the CSS
$pt-line-height: 1.28581
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 different font 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
Javascript
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 Font Variables:</strong> <br /> <br /> </div> <div className= "container" > <p className= 'p1' >text</p> <p className= 'p2' >text</p> <p className= 'p3' >text</p> <p className= 'p4' >text</p> <p className= 'p5' >text</p> <p className= 'p6' >text</p> </div> </div> ); } |
Create a new file, App.scss, and assign different font variables to different paragraphs.
Filename: App.scss
CSS
@import "@blueprintjs/core/lib/scss/variables" ; .container { position : relative ; margin-left : 300px ; } .p 1 { font-family : $pt-font-family; } .p 2 { font-family : $pt-font-family- monospace ; } .p 3 { font-size : $pt-font-size; } .p 4 { font-size : $pt-font-size- small ; } .p 5 { font-size : $pt-font-size- large ; } .p 6 { line-height : $pt-line-height; } |
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 font variables, used by BlueprintJS, but with slight modification by using calc utility function in CSS.
Filename: App.js
Javascript
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 Font Variables:</strong> <br /> <br /> </div> <div className= "container" > <p className= 'p1' >text</p> <p className= 'p2' >text</p> <p className= 'p3' >text</p> <p className= 'p4' >text</p> <p className= 'p5' >text</p> <p className= 'p6' >text</p> </div> </div> ); } |
Create a new file, App.scss, and assign different font variables to different paragraphs.
Filename: App.scss
CSS
@import "@blueprintjs/core/lib/scss/variables" ; .container { position : relative ; margin-left : 300px ; } .p 1 { font-family : $pt-font-family; } .p 2 { font-family : $pt-font-family- monospace ; } .p 3 { font-size : calc( 2 * $pt-font-size); } .p 4 { font-size : calc( 2 * $pt-font-size- small ); } .p 5 { font-size : calc( 2 * $pt-font-size- large ); } .p 6 { line-height : calc( 2 * $pt-line-height); } |
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.font-variables
Please Login to comment...