> For the complete documentation index, see [llms.txt](https://docs.angular-package.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.angular-package.dev/sass/list/list.limit.md).

# list.limit()

The `list.limit()` function returns the list from the first to [`$limit...`](#usdlimit...) index, or from the offset to the limit index.

{% code lineNumbers="true" %}

```scss
// 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
        )
      )...
  );
}
```

{% endcode %}

{% embed url="<https://github.com/angular-package/sass/blob/main/list/_list.limit.function.scss>" %}

### Parameters

#### **`$list`**&#x20;

The list to retrieve the elements from, limited by the [`$limit`](#usdlist).

#### `$limit...`

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

### Return

The return value is [`$list`](#usdlist) of elements specified in [`$limit...`](#usdlimit...).

## Examples

### Limit

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

// Examples.
// limit - number
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 1); // ("a",)
@debug list.limit(('27', '28', '29', 30), 2); // "27", "28"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 2); // "a", "b"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 5); // "a", "b", "c", "d", "e"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 4); // "a", "b", "c", "d"

```

### Offset - limit

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

// Examples.
// offset - limit
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 2, 5); // "b", "c", "d", "e", "f"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 1 4...); // "a", "b", "c", "d"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 2 4...); // "b", "c", "d", "e"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), (2, 5)...); // "b", "c", "d", "e", "f"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), (5, 3)...); // "e", "f", null

```
