Returns the absolute value of a number.
Increases or decreases one or more properties of a color. This can change the red, green, blue, hue, saturation, value, and alpha properties. The properties are specified as keyword arguments, and are added to or subtracted from the color’s current value for that property.
All properties are optional. You can’t specify both RGB properties ($red
, $green
, $blue
) and HSL properties ($hue
, $saturation
, $value
) at the same time.
Changes the hue of a color. Takes a color and a number of degrees (usually between -360deg
and 360deg
), and returns a color with the hue rotated along the color wheel by that amount.
Returns the alpha component (opacity) of a color. This is 1 unless otherwise specified.
This function also supports the proprietary Microsoft alpha(opacity=20)
syntax as a special case.
Appends a single value onto the end of a list.
Unless the $separator
argument is passed, if the list had only one item, the resulting list will be space-separated.
Like all list functions, append()
returns a new list rather than modifying its argument in place.
Gets the blue component of a color. Calculated from HSL where necessary via this algorithm.
Dynamically calls a function. This can call user-defined functions, built-in functions, or plain CSS functions. It will pass along all arguments, including keyword arguments, to the called function.
Rounds a number up to the next whole number.
Changes one or more properties of a color. This can change the red, green, blue, hue, saturation, value, and alpha properties. The properties are specified as keyword arguments, and replace the color’s current value for that property.
All properties are optional. You can’t specify both RGB properties ($red
, $green
, $blue
) and HSL properties ($hue
, $saturation
, $value
) at the same time.
Returns whether two numbers can added, subtracted, or compared.
Returns the complement of a color. This is identical to adjust-hue(color, 180deg)
.
This function only exists as a workaround for IE7‘s content: counter
bug. It works identically to any other plain-CSS function, except it avoids adding spaces between the argument commas.
This function only exists as a workaround for IE7‘s content: counter
bug. It works identically to any other plain-CSS function, except it avoids adding spaces between the argument commas.
Makes a color darker. Takes a color and a number between 0% and 100%, and returns a color with the lightness decreased by that amount.
Makes a color less saturated. Takes a color and a number between 0% and 100%, and returns a color with the saturation decreased by that value.
Returns whether a feature exists in the current Sass runtime.
The following features are supported:
global-variable-shadowing
indicates that a local variable will shadow a global variable unless !global
is used.
extend-selector-pseudoclass
indicates that @extend
will reach into selector pseudoclasses like :not
.
units-level-3
indicates full support for unit arithmetic using units defined in the Values and Units Level 3 spec.
at-error
indicates that the Sass @error
directive is supported.Rounds a number down to the previous whole number.
Check whether a function with the given name exists.
Check whether a variable with the given name exists in the global scope (at the top level of the file).
Converts a color to grayscale. This is identical to desaturate(color, 100%)
.
Gets the green component of a color. Calculated from HSL where necessary via this algorithm.
Creates a Color from hue, saturation, and lightness values. Uses the algorithm from the CSS3 spec.
Creates a Color from hue, saturation, lightness, and alpha values. Uses the algorithm from the CSS3 spec.
Returns the hue component of a color. See the CSS3 HSL specification. Calculated from RGB where necessary via this algorithm.
Converts a color into the format understood by IE filters.
Returns one of two values, depending on whether or not $condition
is true. Just like in @if
, all values other than false
and null
are considered to be true.
Returns the position of a value within a list. If the value isn’t found, returns null
instead.
Note that unlike some languages, the first item in a Sass list is number 1, the second number 2, and so forth.
This can return the position of a pair in a map as well.
Return a string containing the value as its Sass representation.
Returns the inverse (negative) of a color. The red, green, and blue values are inverted, while the opacity is left alone.
Returns whether $super
is a superselector of $sub
. This means that $super
matches all the elements that $sub
matches, as well as possibly additional elements. In general, simpler selectors tend to be superselectors of more complex oned.
Joins together two lists into one.
Unless $separator
is passed, if one list is comma-separated and one is space-separated, the first parameter’s separator is used for the resulting list. If both lists have fewer than two items, spaces are used for the resulting list.
Like all list functions, join()
returns a new list rather than modifying its arguments in place.
Returns the map of named arguments passed to a function or mixin that takes a variable argument list. The argument names are strings, and they do not contain the leading $
.
Return the length of a list.
This can return the number of pairs in a map as well.
Makes a color lighter. Takes a color and a number between 0%
and 100%
, and returns a color with the lightness increased by that amount.
Returns the lightness component of a color. See the CSS3 HSL specification. Calculated from RGB where necessary via this algorithm.
Returns the separator of a list. If the list doesn’t have a separator due to having fewer than two elements, returns space
.
Returns the value in a map associated with the given key. If the map doesn’t have such a key, returns null
.
Returns whether a map has a value associated with a given key.
Returns a list of all keys in a map.
Merges two maps together into a new map. Keys in $map2
will take precedence over keys in $map1
.
This is the best way to add new values to a map.
All keys in the returned map that also appear in $map1
will have the same order as in $map1
. New keys from $map2
will be placed at the end of the map.
Like all map functions, map-merge()
returns a new map rather than modifying its arguments in place.
Returns a new map with keys removed.
Like all map functions, map-merge()
returns a new map rather than modifying its arguments in place.
Returns a list of all values in a map. This list may include duplicate values, if multiple keys have the same value.
Finds the maximum of several numbers. This function takes any number of arguments.
Finds the minimum of several numbers. This function takes any number of arguments.
Mixes two colors together. Specifically, takes the average of each of the RGB components, optionally weighted by the given percentage. The opacity of the colors is also considered when weighting the components.
The weight specifies the amount of the first color that should be included in the returned color. The default, 50%
, means that half the first color and half the second color should be used. 25%
means that a quarter of the first color and three quarters of the second color should be used.
Check whether a mixin with the given name exists.
Gets the nth item in a list.
Note that unlike some languages, the first item in a Sass list is number 1, the second number 2, and so forth.
This can return the nth pair in a map as well.
Negative index values address elements in reverse order, starting with the last element in the list.
Makes a color more opaque. Takes a color and a number between 0 and 1, and returns a color with the opacity increased by that amount.
Returns the alpha component (opacity) of a color. This is 1 unless otherwise specified.
Converts a unitless number to a percentage.
Add quotes to a string if the string isn’t quoted, or returns the same string if it is.
Gets the red component of a color. Calculated from HSL where necessary via this algorithm.
Creates a Color object from red, green, and blue values.
Creates a Color from red, green, blue, and alpha values.
Rounds a number to the nearest whole number.
Makes a color more saturated. Takes a color and a number between 0% and 100%, and returns a color with the saturation increased by that amount.
Returns the saturation component of a color. See the CSS3 HSL specification. Calculated from RGB where necessary via this algorithm.
Fluidly scales one or more properties of a color. Unlike adjust-color, which changes a color’s properties by fixed amounts, scale-color fluidly changes them based on how high or low they already are. That means that lightening an already-light color with scale-color won’t change the lightness much, but lightening a dark color by the same amount will change it more dramatically. This has the benefit of making scale-color($color, ...)
have a similar effect regardless of what $color
is.
For example, the lightness of a color can be anywhere between 0%
and 100%
. If scale-color($color, $lightness: 40%)
is called, the resulting color’s lightness will be 40% of the way between its original lightness and 100. If scale-color($color, $lightness: -40%)
is called instead, the lightness will be 40% of the way between the original and 0.
This can change the red, green, blue, saturation, value, and alpha properties. The properties are specified as keyword arguments. All arguments should be percentages between 0%
and 100%
.
All properties are optional. You can’t specify both RGB properties ($red
, $green
, $blue
) and HSL properties ($saturation
, $value
) at the same time.
Return a new selector with all selectors in $selectors
appended one another as though they had been nested in the stylesheet as $selector1 { &$selector2 { ... } }
.
Returns a new version of $selector
with $extendee
extended with $extender
. This works just like the result of
$selector { ... }
$extender { @extend $extendee }
Return a new selector with all selectors in $selectors
nested beneath one another as though they had been nested in the stylesheet as $selector1 { $selector2 { ... } }
.
Unlike most selector functions, selector-nest
allows the parent selector &
to be used in any selector but the first.
Parses a user-provided selector into a list of lists of strings as returned by &
.
Replaces all instances of $original
with $replacement
in $selector
This works by using @extend
and throwing away the original selector. This means that it can be used to do very advanced replacements; see the examples below.
Unifies two selectors into a single selector that matches only elements matched by both input selectors. Returns null
if there is no such selector.
Like the selector unification done for @extend
, this doesn’t guarantee that the output selector will match all elements matched by both input selectors. For example, if .a .b
is unified with .x .y
, .a .x .b.y, .x .a .b.y
will be returned, but .a.x .b.y
will not. This avoids exponential output size while matching all elements that are likely to exist in practice.
Return a new list, based on the list provided, but with the nth element changed to the value given.
Note that unlike some languages, the first item in a Sass list is number 1, the second number 2, and so forth.
Negative index values address elements in reverse order, starting with the last element in the list.
Returns the simple selectors that comprise the compound selector $selector
.
Note that $selector
must be a compound selector. That means it cannot contain commas or spaces. It also means that unlike other selector functions, this takes only strings, not lists.
Returns the index of the first occurrence of $substring
in $string
. If there is no such occurrence, returns null
.
Note that unlike some languages, the first character in a Sass string is number 1, the second number 2, and so forth.
Inserts $insert
into $string
at $index
.
Note that unlike some languages, the first character in a Sass string is number 1, the second number 2, and so forth.
Returns the number of characters in a string.
Extracts a substring from $string
. The substring will begin at index $start-at
and ends at index $end-at
.
Note that unlike some languages, the first character in a Sass string is number 1, the second number 2, and so forth.
Convert a string to lower case,
Converts a string to upper case.
Makes a color more transparent. Takes a color and a number between 0 and 1, and returns a color with the opacity decreased by that amount.
Returns the type of a value.
Returns a unique CSS identifier. The identifier is returned as an unquoted string. The identifier returned is only guaranteed to be unique within the scope of a single Sass run.
Returns the unit(s) associated with a number. Complex units are sorted in alphabetical order by numerator and denominator.
Returns whether a number has units.
Removes quotes from a string. If the string is already unquoted, this will return it unmodified.
Check whether a variable with the given name exists in the current scope or in the global scope.
Combines several lists into a single multidimensional list. The nth value of the resulting list is a space separated list of the source lists’ nth values.
The length of the resulting list is the length of the shortest list.
© 2006–2016 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
Licensed under the MIT License.
http://sass-lang.com/documentation/Sass/Script/Functions.html