Javatpoint Logo
Javatpoint Logo

Less Type Functions

The Less Type functions are used to determine the type of the value.

A list of Type functions used in Less:

Index Type Description Example
1) isnumber It accepts a value as parameter and returns true, if it's a number otherwise returns false. isnumber(1234); // true
isnumber(24px); // true
isnumber(7.8%); // true
isnumber(#fff); // false
isnumber(red); // false
isnumber("variable"); // false
isnumber(keyword); // false
isnumber(url(...)); // false
2) isstring It accepts a value as parameter and returns true, if it's a string otherwise returns false. isstring("variable"); // true
isstring(1234); // false
isstring(24px); // false
isstring(7.8%); // false
isstring(#fff); // false
isstring(red); // false
isstring(keyword); // false
isstring(url(...)); // false
3) iscolor It accepts a value as parameter and returns true, if value is a color otherwise returns false. iscolor(#fff); // true
iscolor(red); // true
iscolor(1234); // false
iscolor(24px); // false
iscolor(7.8%); // false
iscolor("variable"); // false
iscolor(keyword); // false
iscolor(url(...)); // false
4) iskeyword It accepts a value as parameter and returns true, if value is a keyword otherwise returns false. iskeyword(keyword); // true
iskeyword(1234); // false
iskeyword(24px); // false
iskeyword(7.8%); // false
iskeyword(#fff); // false
iskeyword(red) ; // false
iskeyword("variable");// false
iskeyword(url(...)); // false
5) isurl It accepts a value as parameter and returns true, if value is a url otherwise returns false. isurl(url(...)); // true
isurl(keyword); // false
isurl(1234); // false
isurl(24px); // false
isurl(7.8%); // false
isurl(#fff); // false
isurl(red) ; // false
isurl("variable"); // false
6) ispixel It accepts a value as parameter and returns true, if value is a number in pixels otherwise returns false. ispixel(24px); // true
ispixel(1234); // false
ispixel(7.8%); // false
ispixel(keyword); // false
ispixel(#fff); // false
ispixel(red) ; // false
ispixel("variable"); // falseispixel(url(...)); // false
7) isem It accepts a value as parameter and returns true, if value is an em value otherwise returns false. isem(0.5em); // true
isem(1234); // false
isem(24px); // false
isem(keyword); // false
isem(#fff); // false
isem(red) ; // false
isem("variable"); // false
isem(url(...)); // false
8) ispercentage It accepts a value as parameter and returns true, if value is in percentage otherwise returns false. ispercentage(7.5%); // true
ispercentage(url(...)); // false
ispercentage(keyword); // false
ispercentage(1234); // false
ispercentage(24px); // false
ispercentage(#fff); // false
ispercentage(red) ; // false
ispercentage("variable"); // false
9) isunit It displays true if a value is a number in specified units provided as parameter otherwise false if value is not a number in specified units. isunit(10px, px); // true
isunit(5rem, rem); // true
isunit(7.8%, '%'); // true
isunit(2.2%, px); // false
isunit(24px, rem); // false
isunit(48px, "%"); // false
isunit(1234, em); // false
isunit(#fff, pt); // false
isunit("mm", mm); // false
10) isruleset It accepts a value as parameter and returns true, if value is a ruleset otherwise returns false. @rules: {<div> color: green;<div>}
isruleset(@rules); // true
isruleset(1234); // false
isruleset(24px); // false
isruleset(7.8%); // false
isruleset(#fff); // false
isruleset(blue); // false
isruleset("variable"); // false
isruleset(keyword); // false
isruleset(url(...)); // false
Next TopicLess isnumber()




Please Share

facebook twitter google plus pinterest tumbler

Latest 4 Tutorials