# Starfield

> A deep field of stars drifting in three depths.

Night sky with parallax: near stars drift faster than far ones and each twinkles at its own pace. Density scales with size, so a wide hero matches a small card.

- Family: Backgrounds
- Plan: Creative. Included with Creative.
- Requires: React, Tailwind CSS v4 and the motion package
- Page with a live preview: https://galactrex.com/ui/starfield/
- Licence: https://galactrex.com/ui/license/

## Install

```sh
npx @galactrex/ui login   # once, with an API key from https://galactrex.com/account/
npx @galactrex/ui add starfield
```

It installs to `components/galactrex/starfield.tsx`, with the shared motion helpers beside it. First time in a project: `npx @galactrex/ui init` (setup guide: https://galactrex.com/docs/ui-components-setup/).

## Usage

```tsx
import { Starfield } from "@/components/galactrex/starfield";

<section className="relative overflow-hidden bg-gxui-bg">
  <Starfield />
  <h1 className="relative">Night build</h1>
</section>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `density` | `number` | `30` | Stars per 100,000 square px. |
| `speed` | `number` | `6` | Drift of near stars in px per second; 0 holds still. |
| `twinkle` | `boolean` | `true` | Stars brighten and dim. |
| `opacity` | `number` | `0.9` | Brightest star, 0 to 1. |
| `color` | `string` | `"--gxui-ink"` | CSS colour or --gxui-* name. |
| `className` | `string` | — | Extra classes for the outer element. |

## Variants

- **Drifting.** Slow parallax drift.
- **Still sky.** `speed={0}` keeps only the twinkle.

## Accessibility

- Decorative only and aria-hidden; never takes pointer events.

## Motion

- One canvas; stars are seeded, so the sky is the same on every visit.
- Pauses offscreen.
- Reduced motion: a still sky.
