list.first()

The list.first() function returns the first element of $list.

// Sass.
@use 'sass:list';

// The `list.first()` function.
@function first($list) {
  @return if(type-of($list) == list, list.nth($list, 1), $list);
}

Parameters

$list

The list to get the first element from.

Return

The return value is the first element of $list.

Examples

// Use.
@use 'angular-package/sass/list';

// Examples.
@debug list.first(('a', 'b', c, d, 2, 4, 5, (a: 1))); // ()
@debug list.first(((a: 1), 'b', c, d, 2, 4, 5, (a: 1))); // ((a: 1),)

Last updated