Skip to main content

slice ()

Extracts a portion of a list selecting from a starting index through a ending index.

Parameters

$list
The list to be sliced.
Type
List
$start-at
The index at which to begin extraction. A negative index can be used, indicating an offset from the end of the list.
Type
Number
$end-at
The index through which to end extraction. A negative index can be used, indicating an offset from the end of the list.
Type
Number
Default
-1
$separator
The type of separator to be used by the extracted list.
Type
space | comma | slash | auto
Default
auto

Return Value

List
A list of selected value.

Example

@use '@sass-fairy/list';

$list: 'ant', 'bison', 'camel', 'bison', 'duck', 'elephant';

@debug list.slice($list, 3);
// 'camel', 'bison', 'duck', 'elephant'

@debug list.slice($list, 3, 5);
// 'camel', 'bison', 'duck'

@debug list.slice($list, -3);
// 'bison', 'duck', 'elephant'