---
title: "length"
description: "The length of a vector."
group: "space"
groupTitle: "Shapes, frames & warps"
categoryId: "math"
categorySlug: "math"
categoryTitle: "Math"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/math.ts#L316"
---

# length

The length of a vector.

```ts
length(v: Val): Expr
```

Import `math` from `shaders/std` and use `math.length`.

The distance from the origin, or from a center when you pass the offset from it.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `v` | `Val` |  |

## Example

```ts
const dist = length(sub(uv, params.uniforms.center))
```

## See also

- [`distance`](/docs/primitives/math/distance) — The distance between two points.
- [`normalize`](/docs/primitives/math/normalize) — The vector scaled to length 1.

## Used by

[Chrome](/docs/components/chrome), [LiquidMetal](/docs/components/liquidmetal), [MeshGradient](/docs/components/meshgradient), [Water](/docs/components/water)