---
title: "Change: spray"
description: A burst of particles fans upward from an element when a value changes.
---

Spray throws a short burst of particles up and out of the element. It fits a reward moment, such as a like, a favorite or a purchase.

## Usage

The sample sprays red hearts when the like count goes up. It uses a particle layer so the hearts are not clipped by the list around them.

```kotlin
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.jantursky.kapow.ChangeEffect
import com.jantursky.kapow.ParticleContent
import com.jantursky.kapow.ParticleShape
import com.jantursky.kapow.changeEffect

@Composable
fun LikeButton(likes: Int) {
    BasicText(
        text = "Likes: $likes",
        modifier = Modifier.changeEffect(
            value = likes,
            effect = ChangeEffect.spray(
                particles = ParticleContent.shape(
                    shape = ParticleShape.Heart,
                    colors = listOf(Color.Red, Color(0xFFFF6B5A)),
                    size = 12.dp,
                ),
                count = 14,
            ),
        ),
    )
}
```

## Parameters

| Parameter | Default | Description |
| --- | --- | --- |
| `particles` | `ParticleContent.shape()` | What each particle looks like. `ParticleContent.shape(shape, colors, size)` draws a built-in shape (`Circle`, `Square`, `Star`, `Heart`, `Sparkle`), taking colors in turn. `ParticleContent.painter(painter, size, tint)` draws an icon or image. The default is a 14 dp sparkle in amber, coral, violet and cobalt. |
| `count` | `11` | How many particles one change sprays. Must be positive. |
| `physics` | `ParticlePhysics.Default` | How the particles launch and move: direction and spread, speed, gravity, drag, lifetime, size, spin, start and end scale, fade curve, emission area, blend mode and color pick. Parts you leave out keep the spray's own values: a 100 degree fan around straight up, 380 to 620 dp per second, 600 dp per second squared of gravity. Every part applies to spray. |
| `origin` | `TransformOrigin.Center` | Where the particles start, as fractions of the element's width and height. An `EmissionArea` in the physics is centered on it. |
| `rotation` | `-30f..30f` | The range each particle's starting angle is picked from, in degrees. Their turning speed comes from `physics`. |
| `seed` | `0` | The first seed. Each change takes the next one, so the same seed gives the same sprays in the same order. |

## Reduced motion

No particles are emitted. The element brightens briefly. With `reducedMotion(ReducedMotionMode.EndState)` nothing shows at all, since the effect ends at rest.

## Notes

- Particles draw through a [particle layer](/guides/particle-layer) when one is above the element, so a clipping parent does not cut them off. Without one they draw around the element.
- The particles fan upward, scale in, then fade. A burst is gone in about a second.
- There is no cooldown, so quick changes start overlapping bursts.
- A `painter` should be remembered.
- Particles that are in flight do not follow the element if it moves or scrolls.

## Flash safety

`spray` moves particles and does not flash, so `LocalKapowMaxFlashesPerSecond` does not limit it. Only the effects that flash are limited: `flash`, `glitch` and `repeat` of one of them, plus the rings of `ping`. See the [accessibility guide](/guides/accessibility).

## Live example

<iframe class="live-example" src="https://kapow-demo.vercel.app/#change-spray" title="Live example: change-spray" loading="lazy" allow="autoplay"></iframe>
