---
title: "Bounce"
description: "Any node, or a trail of photos, moves in a line and bounces off the edges of its box. Each wall hit sets the next color, and a corner hit glows."
url: https://gelatinui.com/components/bounce
markdown_url: https://gelatinui.com/components/bounce.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/bounce"
version: "2026-11-11"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Bounce

> Any node, or a trail of photos, moves in a line and bounces off the edges of its box. Each wall hit sets the next color, and a corner hit glows.

Page: https://gelatinui.com/components/bounce

## When to use it

Best for: Any node, or a trail of photos, that moves in a line and bounces off the edges of its box.

- Use one child for the classic bouncing badge, or many for a trail on one path.
- Use `--bounce-color` in a child to take the color of the last wall hit.
- Use `onCornerHit` to count or react to a corner hit.

## When not to use it

- For text or logos that scroll in a row, use a [Marquee](https://gelatinui.com/components/marquee.md).
- For a layer that moves with the scroll, use [Parallax](https://gelatinui.com/components/parallax.md).

## Notes for agents

- Give each child a `key`: text with no element is left out.
- The box needs a size; Bounce fills it (`size-full`).
- A new `speed` keeps the place; a new `gap`, `angle`, `colors`, or child list lays the scene out again.
- It runs only on screen, in a visible tab, and while its Screensaver shows.

## Anatomy

```text
Bounce
```

## API reference

### Bounce

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `gap` | `number` | 48 | The distance between trail items along the path, in px. Default 48. |
| `speed` | `number` | 120 | Speed along the path, in px per second. Default 120. |
| `angle` | `number` | 45 | The start direction in degrees (0 is right, 90 is down). Default 45. |
| `colors` | `readonly string[]` | AURORA_COLORS | The colors that `--bounce-color` steps through, one per edge hit (any CSS color). A child that wants the color reads the variable (`border-(--bounce-color)`). Default: the aurora. |
| `onCornerHit` | `function` |  | Called when the leader hits a corner. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Bounce | `bounce` |  | `--bounce-color` |  |

## Usage

Put the children in a box with a size. Each child needs a key.

```tsx title="photo-bounce.tsx"
import { Bounce } from "@/components/pro/screensavers/bounce";

export function PhotoBounce() {
  return (
    <div className="h-80 overflow-hidden rounded-2xl bg-neutral-950">
      <Bounce gap={44}>
        <img key="lake" src="/lake.webp" alt="A lake" width={104} height={130} />
        <img key="hills" src="/hills.webp" alt="Hills" width={104} height={130} />
      </Bounce>
    </div>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui-pro/bounce
```

It adds 19 registry items: 18 files, 1838 lines, and the npm packages `@mantine/hooks`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Screensaver](https://gelatinui.com/components/screensaver.md)
- [Starfield](https://gelatinui.com/components/starfield.md)
- [Marquee](https://gelatinui.com/components/marquee.md)
- [Parallax](https://gelatinui.com/components/parallax.md)

## Motion

| Part | Motion |
| --- | --- |
| Corner hit | theme · the glow in the corner fades in and out |
| Drift | none · each frame writes one transform per item, at `speed` px a second |
