Sass nth() Function

Last Updated:

Sass nth() Function

The nth() function returns the element of a list at the specified index.

Example

SASS TO CSS CONVERTER
//Check your console @debug nth(10px 20px 30px, 2); // 20px @debug nth(['#fff', '#000', '#8c8c8c'], -1); // #8c8c8c

Syntax

nth($list, $n)

Parameter Value

ValueTypeExplanation
$list Required Specifies a list.
$n Required Specifies the index value in the list.
  • If $n is positive, it counts from the start of $list
  • If $n is negative, it counts from the end of $list
  • Throws an error if there is no element at index $n.

Return Value

ValueExplanation
string Returns the element of $list at index $n.

Share this Page

Meet the Author