⊗mkLsBsFMOP 24 of 41 menu

Multiple optional parameters in functions in LESS

If a function has multiple parameters, the optional parameters should be placed at the end. Let's look at an example.

Let's say we have a function that sets the text color and the background color at the same time:

.color(@c1, @c2) { color: @c1; background-color: @c2; }

Let's make the second parameter optional:

.color(@c1, @c2: white) { color: @c1; background-color: @c2; }

Now let's make it so that the first parameter is optional:

.color(@c1: black, @c2: white) { color: @c1; background-color: @c2; }

Make a function border that defines a border. Let it take three parameters: thickness, color, and border type. Let the function by default create a border with a thickness of 1px, a color of black, and a type of solid.

enru