list.limit()

The list.limit() function returns the list from the first to $limit... index, or from the offset to the limit index.

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

// Functions.
@use 'list.range.function' as *;

// The `list.limit()` function.
@function limit($list, $limit...) {
  @return range(
    $list,
    if(
        list.length($limit) == 1,
        list.join(1, $limit, comma),
        list.join(
          list.nth($limit, 1),
          calc(list.nth($limit, 1) + list.nth($limit, 2) - 1),
          comma
        )
      )...
  );
}
https://github.com/angular-package/sass/blob/main/list/_list.limit.function.scss

Parameters

$list

The list to retrieve the elements from, limited by the $limit.

$limit...

A number of the indexes of the returned list from first, or given offset.

Return

The return value is $list of elements specified in $limit....

Examples

Limit

Offset - limit

Last updated

Was this helpful?