Skip to main content
Version: 1.1.x

List

Because the sass:list module already, the namespace is prefixed with an underscore to avoid conflict.

@use "@glsass/tools/tools.list" as _list;

first()

Since v1.0.0

Retrieves the first element of a list.

_list.first($list);

_list.first(("one", "two", "three"));
// Returns "one"

last()

Since v1.0.0

Retrieves the last element of a list.

_list.last($list);

_list.last(("one", "two", "three"));
// Returns "three"

prepend()

Since v1.0.0

Add new values at beginning of the list (opposite logic of list.append).

prepend($list);

prepend(("one", "two", "three"), "zero");
// Returns ("zero", "one", "two", "three")

to-string()

Since v1.0.0

Convert a list into the string, with the ability to use a string to join elements with each others.

to-string($list, $glue: "", $is-nested: false);

to-string(("a", "b", "c"));
// Returns "abc"

to-string(("block", "element", "modifier"), "-");
// Returns "block-element-modifier"

is-empty()

Since v1.0.0

Indicates if the list is empty.

is-empty($list);

is-empty(("one", "two", "three"));
// Returns false

is-empty(());
// Returns true