---
title: "beam"
description: "A glowing beam of light between two points."
group: "paint"
groupTitle: "Painting"
categoryId: "gradients"
categorySlug: "gradients"
categoryTitle: "Gradients"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/paint/gradients.ts#L194"
---

# beam

A glowing beam of light between two points.

```ts
beam(slots: {
    from: PropRef
    to: PropRef
    thickness: {start: ArgSpec; end: ArgSpec}
    softness: {start: ArgSpec; end: ArgSpec}
    colors: {inside: PropRef; outside: PropRef}
    space: PropRef
}): Paint
```

Import `gradients` from `shaders/std` and use `gradients.beam`.

`from` and `to` are position props (made with `transformPosition`). `thickness` (0–2) and `softness` each take a `start` and `end` value so the beam can taper. The cross-section shades from `colors.inside` at the core to `colors.outside` at the edge, mixed in the color space named by the `space` prop (mark it `compileTime`). Declare `extraFields: beamPreconvertedFields` on the definition.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `slots` | `{
    from: PropRef
    to: PropRef
    thickness: {start: ArgSpec; end: ArgSpec}
    softness: {start: ArgSpec; end: ArgSpec}
    colors: {inside: PropRef; outside: PropRef}
    space: PropRef
}` |  |

## Example

```ts
paint: beam({from: p('startPosition'), to: p('endPosition'), thickness: {start: p('startThickness'), end: p('endThickness')}, softness: {start: p('startSoftness'), end: p('endSoftness')}, colors: {inside: p('insideColor'), outside: p('outsideColor')}, space: p('colorSpace')})
```

## See also

- [`beamPreconvertedFields`](/docs/primitives/gradients/beampreconvertedfields) — The `extraFields` a `beam` definition must declare.

## Used by

[Beam](/docs/components/beam)