---
title: "Starfield"
description: "Stars fly out from a point, grow near the viewer, and streak with the speed. On a canvas, for a hero or a screensaver."
url: https://gelatinui.com/components/starfield
markdown_url: https://gelatinui.com/components/starfield.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/starfield"
version: "2026-11-11"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Starfield

> Stars fly out from a point, grow near the viewer, and streak with the speed. On a canvas, for a hero or a screensaver.

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

## When to use it

Best for: Stars that fly out from a point behind a dark hero, a countdown, or a clock.

- Use `speed` from 1 (a cruise) to 2.5 (a warp).
- Use `origin` to move the point the stars come from.
- Use `streaks={false}` for round stars on a calm display.

## When not to use it

- For soft lines that drift, use [Ribbons](https://gelatinui.com/components/ribbons.md).
- For logos that scroll in a row, use a [Marquee](https://gelatinui.com/components/marquee.md).

## Notes for agents

- It draws on a canvas that fills its box: give the box a size.
- `count` is for a 1280 × 720 stage and scales with the area.
- A new `speed`, `count`, `color`, or `origin` starts the scene again.

## Anatomy

```text
Starfield
```

## API reference

### Starfield

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `color` | `string` | "oklch(1 0 0)" | The star color (any CSS color). Default white. |
| `count` | `number` | 400 | Stars on a 1280 × 720 stage; scaled by the stage area. Default 400. |
| `speed` | `number` | 1 | How fast the stars come near: 1 is a cruise, 2.5 a warp. Default 1. |
| `streaks` | `boolean` | true | Draw each star as a streak that grows with speed. Default true. |
| `origin` | `Readonly<{ x: number; y: number }>` |  | Where the stars come from, as fractions of the stage. Default the center. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Starfield | `starfield` |  |  |  |

## Usage

Put Starfield behind your content in a dark box with a size.

```tsx title="launch-hero.tsx"
import { Starfield } from "@/components/pro/screensavers/starfield";

export function LaunchHero() {
  return (
    <section className="relative isolate h-96 overflow-hidden rounded-2xl bg-neutral-950">
      <Starfield className="absolute inset-0 -z-10" count={320} speed={0.6} />
    </section>
  );
}
```

## 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/starfield
```

It adds 26 registry items: 26 files, 2453 lines, and the npm packages `@mantine/hooks`, `clsx`, `motion`, `tailwind-merge`.

## 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)
- [Ribbons](https://gelatinui.com/components/ribbons.md)
- [Pipes](https://gelatinui.com/components/pipes.md)
- [Marquee](https://gelatinui.com/components/marquee.md)
- [Parallax](https://gelatinui.com/components/parallax.md)
