Nebula
wise-ui/nebulaFreeComponent
An animated nebula cloud background using WebGL shaders.
Live preview
live · rendered by the registry
Rendered by wise-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://wise-ui.com/r/nebula.jsonSource
1"use client"23import * as React from "react"4import { cn } from "@/lib/utils"56interface NebulaProps extends React.HTMLAttributes<HTMLDivElement> {7 /** Primary nebula color */8 colorA?: string9 /** Secondary nebula color */10 colorB?: string11 /** Tertiary accent color */12 colorC?: string13 /** Show grain/star dust overlay */14 grain?: boolean15 /** Animation speed multiplier (1 = default) */16 speed?: number17 /** Number of nebula blobs */18 blobCount?: number19 /** Visual mode - "dark" for space theme, "light" for bright/pastel */20 mode?: "dark" | "light"21}2223function hexToRgba(hex: string, alpha: number): string {24 const r = parseInt(hex.slice(1, 3), 16)25 const g = parseInt(hex.slice(3, 5), 16)26 const b = parseInt(hex.slice(5, 7), 16)27 return `rgba(${r},${g},${b},${alpha})`28}2930const Nebula = React.forwardRef<HTMLDivElement, NebulaProps>(31 (32 {33 colorA = "#6b1d9e",34 colorB = "#0d3b7a",35 colorC = "#c2185b",36 grain = true,37 speed = 1,38 blobCount = 18,39 mode = "dark",40 className,41 children,42 ...props43 },44 ref45 ) => {46 const isDark = mode === "dark"47 const bgColor = isDark ? "#080012" : "#f4f0f8"48 const canvasRef = React.useRef<HTMLCanvasElement>(null)49 const containerRef = React.useRef<HTMLDivElement>(null)50 const uniqueId = React.useId()51 const filterId = `nebula-grain-${uniqueId}`5253 React.useImperativeHandle(ref, () => containerRef.current!)5455 React.useEffect(() => {56 const canvas = canvasRef.current57 const container = containerRef.current58 if (!canvas || !container) return5960 const ctx = canvas.getContext("2d")61 if (!ctx) return6263 let w = 064 let h = 065 let rafId = 06667 const colors = [colorA, colorB, colorC]6869 interface Blob {70 x: number71 y: number72 r: number73 color: string74 phaseX: number75 phaseY: number76 freqX: number77 freqY: number78 ampX: number79 ampY: number80 rotPhase: number81 rotSpeed: number82 }8384 let blobs: Blob[] = []8586 function initBlobs() {87 blobs = Array.from({ length: blobCount }, (_, i) => {88 const color = colors[i % colors.length]89 return {90 x: Math.random() * w,91 y: Math.random() * h,92 r: Math.max(w, h) * (0.15 + Math.random() * 0.25),93 color,94 phaseX: Math.random() * Math.PI * 2,95// … truncated
What it pulls in
npm packages
Files it writes
More from wise-ui
All 20 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Tabsanimated-tabs | wise-ui | Components | Free | 3 deps | |
| Border Beamborder-beam | wise-ui | Components | Free | 3 deps | |
| Data Tabledata-table | wise-ui | Components | Free | 3 deps | |
| Dockdock | wise-ui | Components | Free | 3 deps | |
| Dot Matrixdot-matrix | wise-ui | Components | Free | 2 deps | |
| Editable Texteditable-text | wise-ui | Components | Free | 4 deps | |
| Gradient Sidebargradient-sidebar | wise-ui | Components | Free | 3 deps | |
| Kanban Boardkanban-board | wise-ui | Components | Free | 6 deps |
