Open In App

Less.js Type isstring() Function

Last Updated : 06 Oct, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. Because CSS uses a dynamic style sheet language, it is more beneficial. Because of LESS’ adaptability, it may be used by numerous different browsers. CSS must be created and improved using a computer language known as the CSS pre-processor in order for web browsers to use it. Along with providing tools like variables, functions, mixins, and operations to help construct dynamic CSS while maintaining backward compatibility, it is also a CSS language extension.

In this article, we are going to discuss the Type isstring() function, whose function is to determine whether a value given is a string or not. This function returns a Boolean value.

Syntax:

isstring(value)

 

Parameters:

  • value: This is the only compulsory parameter for this function.

Compile LESS code into CSS code

Example 1: The code below demonstrates the usage and implementation of the Type isstring() function.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <link rel="stylesheet" 
        type="text/css" href="styles.css" />
</head>
  
<body>
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
      
    <h3>Less.js Type isstring() Function</h3>
      
    <div class="c1">
        <p>isstring("50%")<br>TRUE</p>
        <p>isstring(50%)<br>FALSE</p>
    </div>
</body>
  
</html>


styles.less




@body-bg-color: #eeeeee;
@dark: hsl(25, 71%, 8%);
@light1: rgb(253, 255, 146);
@light2: rgb(255, 155, 146);
@cond1: boolean(isstring("50%"));
@cond2: boolean(isstring(50%));
  
body {
    background-color: @body-bg-color;
}
  
.c1 {
    width: 250px;
    height: 150px;
    margin: 1rem;
    background-color: if(@cond1, @dark, @light);
    padding: 20px 0px 0px 55px;
}
  
p {
    color: if(@cond2, @light1, @light2);
}


Syntax: To compile the above LESS code to CSS code, run the following command.

lessc styles.less styles.css

styles.css: The compiled CSS file is as follows.

styles.css




body {
    background-color: #eeeeee;
}
  
.c1 {
    width: 250px;
    height: 150px;
    margin: 1rem;
    background-color: hsl(25, 71%, 8%);
    padding: 20px 0px 0px 55px;
}
  
p {
    color: #ff9b92;
}


Output:

 

Example 2: The code below demonstrates the usage and implementation of the Type isstring() function with the if and boolean logical functions and the saturation color channel function.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <link rel="stylesheet" 
        type="text/css" href="styles.css" />
</head>
  
<body>
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
      
    <h3>Less.js Type isstring() Function</h3>
      
    <div class="c1">
        <p>isstring(String of Saturation)<br>TRUE</p>
    </div>
</body>
  
</html>


styles.less




/* styles.less */
@body-bg-color: #eeeeee;
@dark: hsl(222, 100%, 24%);
@light: rgb(255, 160, 138);
@cond1: boolean(isstring("saturation(rgb(77, 168, 54))"));
  
body {
    background-color: @body-bg-color;
}
  
.c1 {
    width: 250px;
    height: 150px;
    margin: 1rem;
    background-color: if(@cond1, @light, @dark);
}
  
p {
    padding: 50px 0px 0px 30px;
    color: if(@cond1, @dark, @light);
}


Syntax: To compile the above LESS code to CSS code, run the following command.

lessc styles.less styles.css

styles.css: The compiled CSS file is as follows:

styles.css




/* styles.less */
body {
    background-color: #eeeeee;
}
  
.c1 {
    width: 250px;
    height: 150px;
    margin: 1rem;
    background-color: #ffa08a;
}
  
p {
    padding: 50px 0px 0px 30px;
    color: hsl(222, 100%, 24%);
}


Output:

 

Reference: https://lesscss.org/functions/#type-functions-isstring 



Similar Reads

AngularJS | angular.isString() Function
The angular.isString() function in AngularJS is used to determine the parameter inside isString function is a string or not. It returns true if the reference is a string otherwise returns false. Syntax: angular.isString( value ) Return Value: It returns true if the value passed is a string otherwise return false. Example: This example uses angular.
1 min read
Underscore.js _.isString() Function
The _.isString() function is used to check whether the given object element is string or not. Syntax: _.isString( object ) Parameters: This function accepts single parameter as mentioned above and described below: object: It contains the value of object that need to be check whether it is an string or not. Return Value: It returns a Boolean value T
1 min read
Lodash _.isString() Method
Lodash _.isString() method is used to find whether the given value is a string object or not. It returns True if the given value is a string. Otherwise, it returns false. Syntax:_.isString(value);Parameters: value: This parameter holds the value to check.Return Value: This method returns true if the value is a string, else false. Example 1: In this
1 min read
Less.js Type isunit() Function
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. Because CSS uses a dynamic style sheet language, it is more beneficial. Due to LESS adaptability, it may be used by numerous different browsers. CSS must be created and improved using a computer language known as
2 min read
Less.js Type ispercentage() Function
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. It is more advantageous because CSS employs a dynamic style sheet language. Several different browsers can use LESS because of its flexibility. In order for web browsers to use CSS, it must be built and enhanced u
3 min read
Less.js Type isnumber() Function
In this article, we are going to take a look on isnumber() function in Less.js. Less (Leaner Style Sheets) is an extension to normal CSS which is basically used to enhance the abilities of regular CSS code and provide it superpowers. The isnumber() function is a Type Function in Less.js (which is basically used to check whether the given argument i
3 min read
Less.js Type isurl() Function
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. It is better since CSS uses a dynamic style sheet language. LESS is flexible enough to be utilized by a wide range of browsers. Web browsers can only use CSS if it is developed and refined using a computer languag
3 min read
Less.js Type iscolor() Function
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. Because CSS uses a dynamic style sheet language, it is more beneficial. Because of LESS adaptability, it may be used by numerous different browsers. CSS must be created and improved using a computer language known
3 min read
Less.js Type isdefined() Function
Less (Leaner Style Sheets) is an extension to normal CSS which basically enhances the abilities of normal CSS code and provides superpowers to it. In this article, we are going to take a look at the isdefined() function in Less.js. The isdefined() function is a Type Function in Less.js which is used to find out whether the given argument or the giv
2 min read
Less.js Type isem() Function
Less (Leaner style sheet) is an extension to normal CSS which is basically used to enhance the abilities of normal CSS code and provide it superpowers. isem() function is a Type Function in Less.js (which is basically used to check the type of the given parameter). isem() function is used to find out whether the given argument is an em value or not
3 min read