General · Full page

The general blocks stacked into one page: glass navbar, aurora hero, split hero with a horizon beam, and the gradient footer.

Blocks
landingpagetemplateheronavbar
New · shinUI components

Design faster, ship something beautiful

Backgrounds, components and blocks you can drop into any React + Tailwind project. Free, open and built to be remixed.

shinUI · studio drop

Build the part nobody else has.

Original blocks and backgrounds, tuned in the gallery, then shipped as registry installs or an npm package.

Format

Registry + npm

© 2026 shinUI, Inc.

Usage

Drop the file into your project, along with the shared files listed below, and import it.

usage.tsx
import { GeneralLanding } from "@/registry/blocks/general-landing";

export function Example() {
  return <GeneralLanding />;
}

Install prerequisites

Every component here relies only on Tailwind and the cn helper from shadcn/ui.

terminal
npm i clsx tailwind-merge

Also copy these files

General · Full page imports these files. Keep the same paths, or update the imports to match.

src/registry/blocks/navbar.tsx
'use client'

import { useState, type ComponentProps } from 'react'
import { Button } from '@/registry/components/button'
import { cn } from '@/lib/utils'

const variants = {
  // Avoid backdrop-blur here — it can black-screen Edge/Windows GPU compositors
  // when many previews mount on the gallery page.
  glass: 'border-b border-border bg-background/95',
  solid: 'border-b border-border bg-ds-surface',
  minimal: 'bg-transparent',
} as const

export interface NavbarProps extends ComponentProps<'header'> {
  brand?: string
  /** Link labels, as an array or a comma-separated string. */
  links?: string[] | string
  ctaLabel?: string
  showSignIn?: boolean
  variant?: keyof typeof variants
}

/** Responsive top navigation with a mobile menu below the md breakpoint. */
export function Navbar({
  className,
  brand = 'shinUI',
  links = ['Product', 'Components', 'Pricing', 'Docs'],
  ctaLabel = 'Get started',
  showSignIn = true,
  variant = 'glass',
  ...props
}: NavbarProps) {
  const [open, setOpen] = useState(false)
  const items = typeof links === 'string' ? links.split(',').map((l) => l.trim()).filter(Boolean) : links

  return (
    <header className={cn('relative z-20 w-full', variants[variant], className)} {...props}>
      <nav className="mx-auto flex h-16 max-w-6xl items-center justify-between gap-6 px-6">
        <a href="#" className="flex items-center gap-2 font-display text-lg font-semibold tracking-tight">
          <span className="size-6 rounded-md bg-[linear-gradient(135deg,var(--ds-primary),var(--ds-accent))] shadow-[0_0_16px_-2px_var(--ds-primary)]" />
          {brand}
        </a>

        <ul className="hidden items-center gap-1 md:flex">
          {items.map((label) => (
            <li key={label}>
              <a href="#" className="rounded-md px-3 py-2 text-sm text-ds-muted transition-colors hover:text-foreground">
                {label}
              </a>
            </li>
          ))}
        </ul>

        <div className="hidden items-center gap-2 md:flex">
          {showSignIn && (
            <Button variant="ghost" size="sm">
              Sign in
            </Button>
          )}
          <Button size="sm">{ctaLabel}</Button>
        </div>

        <button
          type="button"
          aria-label={open ? 'Close menu' : 'Open menu'}
          aria-expanded={open}
          onClick={() => setOpen((o) => !o)}
          className="relative grid size-9 cursor-pointer place-items-center rounded-md border border-border md:hidden"
        >
          <span className={cn('absolute h-px w-4 bg-current transition-transform', open ? 'rotate-45' : '-translate-y-1')} />
          <span className={cn('absolute h-px w-4 bg-current transition-transform', open ? '-rotate-45' : 'translate-y-1')} />
        </button>
      </nav>

      {open && (
        <div className="border-t border-border px-6 pt-2 pb-4 md:hidden">
          <ul className="flex flex-col">
            {items.map((label) => (
              <li key={label}>
                <a href="#" className="block rounded-md py-2.5 text-sm text-ds-muted hover:text-foreground">
                  {label}
                </a>
              </li>
            ))}
          </ul>
          <div className="mt-3 flex flex-col gap-2">
            {showSignIn && (
              <Button variant="secondary" className="w-full">
                Sign in
              </Button>
            )}
            <Button className="w-full">{ctaLabel}</Button>
          </div>
        </div>
      )}
    </header>
  )
}
src/registry/blocks/hero.tsx
'use client'

import { Aurora } from '@/registry/backgrounds/aurora'
import { Button } from '@/registry/components/button'
import { cn } from '@/lib/utils'

export interface HeroProps {
  eyebrow?: string
  title?: string
  description?: string
  primaryCta?: string
  secondaryCta?: string
  showSecondary?: boolean
  /** Animated shimmer across the headline. */
  shimmer?: boolean
  align?: 'center' | 'left'
  background?: 'vivid' | 'subtle'
  className?: string
}

export function Hero({
  eyebrow = 'New · shinUI components',
  title = 'Design faster, ship something beautiful',
  description = 'Backgrounds, components and blocks you can drop into any React + Tailwind project. Free, open and built to be remixed.',
  primaryCta = 'Get started',
  secondaryCta = 'Browse components',
  showSecondary = true,
  shimmer = true,
  align = 'center',
  background = 'vivid',
  className,
}: HeroProps) {
  const centered = align === 'center'

  return (
    <Aurora intensity={background} className={cn('px-6 py-24', className)}>
      <div className={cn('mx-auto flex max-w-5xl flex-col', centered ? 'items-center text-center' : 'items-start text-left')}>
        {eyebrow && (
          <span className="mb-6 inline-flex items-center gap-2 rounded-full border border-border bg-ds-surface/90 px-3 py-1 text-xs text-ds-muted">
            <span className="size-1.5 rounded-full bg-ds-accent shadow-[0_0_8px_var(--ds-accent)]" />
            {eyebrow}
          </span>
        )}
        <h1
          className={cn(
            'max-w-3xl font-display text-4xl font-semibold tracking-tight text-balance sm:text-6xl',
            shimmer &&
              'animate-ds-shimmer bg-[linear-gradient(110deg,var(--color-foreground)_35%,var(--ds-accent)_50%,var(--color-foreground)_65%)] bg-size-[200%_100%] bg-clip-text text-transparent motion-reduce:animate-none',
          )}
        >
          {title}
        </h1>
        <p className="mt-6 max-w-xl text-base text-pretty text-ds-muted sm:text-lg">{description}</p>
        <div className={cn('mt-10 flex flex-wrap items-center gap-3', centered && 'justify-center')}>
          <Button size="lg">{primaryCta}</Button>
          {showSecondary && (
            <Button size="lg" variant="secondary">
              {secondaryCta}
            </Button>
          )}
        </div>
      </div>
    </Aurora>
  )
}
src/registry/blocks/split-hero.tsx
'use client'

import { Button } from '@/registry/components/button'
import { HorizonBeam } from '@/registry/backgrounds/horizon-beam'
import { cn } from '@/lib/utils'

export interface SplitHeroProps {
  kicker?: string
  title?: string
  description?: string
  primaryCta?: string
  secondaryCta?: string
  showSecondary?: boolean
  metaLabel?: string
  metaValue?: string
  className?: string
}

/**
 * Editorial split hero: oversized type on the left, meta + CTAs on the right,
 * over a horizon beam — distinct from the centered Aurora hero.
 */
export function SplitHero({
  kicker = 'shinUI · studio drop',
  title = 'Build the part nobody else has.',
  description = 'Original blocks and backgrounds, tuned in the gallery, then shipped as registry installs or an npm package.',
  primaryCta = 'Start a block',
  secondaryCta = 'Browse backgrounds',
  showSecondary = true,
  metaLabel = 'Format',
  metaValue = 'Registry + npm',
  className,
}: SplitHeroProps) {
  return (
    <HorizonBeam color="var(--ds-highlight)" altitude={62} thickness="thin" className={cn('px-6 py-24', className)}>
      <div className="mx-auto grid max-w-6xl gap-12 md:grid-cols-[1.4fr_0.8fr] md:items-end md:gap-16">
        <div>
          <p className="font-mono text-[11px] tracking-[0.22em] text-ds-muted uppercase">{kicker}</p>
          <h1 className="mt-5 max-w-xl font-display text-4xl font-semibold tracking-tight text-balance sm:text-6xl">
            {title}
          </h1>
        </div>
        <div className="flex flex-col gap-8 md:pb-1">
          <p className="max-w-sm text-base text-pretty text-ds-muted sm:text-lg">{description}</p>
          <div className="flex flex-wrap items-center gap-3">
            <Button size="lg">{primaryCta}</Button>
            {showSecondary && (
              <Button size="lg" variant="secondary">
                {secondaryCta}
              </Button>
            )}
          </div>
          <div className="border-t border-border pt-4">
            <p className="font-mono text-[10px] tracking-wider text-ds-muted uppercase">{metaLabel}</p>
            <p className="mt-1 text-sm font-medium">{metaValue}</p>
          </div>
        </div>
      </div>
    </HorizonBeam>
  )
}
src/registry/footers/footer-gradient.tsx
'use client'

import { type CSSProperties } from 'react'
import { BottomBar, Brand, FooterColumns, FooterRoot, useReducedMotion } from '@/registry/footers/footer-kit'
import { cn } from '@/lib/utils'

export interface FooterGradientProps {
  brand?: string
  tagline?: string
  /** Lead color of the gradient. */
  accent?: string
  /** aurora: accent + teal + violet. sunset: accent + coral + gold. mono: shades of the accent. */
  palette?: 'aurora' | 'sunset' | 'mono'
  animate?: boolean
  /** Glow strength, 0 to 1. */
  intensity?: number
  /** Film grain over the glow. */
  grain?: boolean
  className?: string
}

const PALETTES = {
  aurora: ['#2dd4bf', '#a855f7', '#3b82f6'],
  sunset: ['#fb7185', '#fbbf24', '#f97316'],
  mono: ['color-mix(in oklab, var(--ft-accent) 55%, white)', 'color-mix(in oklab, var(--ft-accent) 70%, black)', 'var(--ft-accent)'],
} as const

const NOISE =
  "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E\")"

const KEYFRAMES = `
@keyframes ft-blob-a{0%,100%{transform:translate(0,0) scale(1)}50%{transform:translate(18%,-12%) scale(1.15)}}
@keyframes ft-blob-b{0%,100%{transform:translate(0,0) scale(1.1)}50%{transform:translate(-20%,10%) scale(.9)}}
@keyframes ft-blob-c{0%,100%{transform:translate(0,0) rotate(0)}50%{transform:translate(10%,14%) rotate(40deg)}}
@keyframes ft-pan{0%,100%{background-position:0% 50%}50%{background-position:100% 50%}}
`

/** A soft aurora glow rising from the bottom, with a giant wordmark clipped to the same gradient. */
export function FooterGradient({
  brand = 'lumen',
  tagline = 'Light work for heavy problems.',
  accent = '#8b5cf6',
  palette = 'aurora',
  animate = true,
  intensity = 0.8,
  grain = true,
  className,
}: FooterGradientProps) {
  const reduced = useReducedMotion()
  const moving = animate && !reduced
  const [a, b, c] = PALETTES[palette]
  const glow = Math.max(0, Math.min(1, intensity))
  const anim = (name: string, s: number) => (moving ? `${name} ${s}s ease-in-out infinite` : 'none')
  const blob = 'absolute rounded-full blur-[80px] mix-blend-normal dark:mix-blend-screen'

  return (
    <FooterRoot accent={accent} className={cn('bg-(--ft-bg)', className)}>
      <style>{KEYFRAMES}</style>
      <div aria-hidden className="absolute inset-0 -z-10 overflow-hidden" style={{ opacity: 0.35 + glow * 0.65 }}>
        <div className={cn(blob, 'ft-anim -bottom-1/3 left-[-10%] h-[80%] w-[55%]')} style={{ background: 'var(--ft-accent)', animation: anim('ft-blob-a', 16) }} />
        <div className={cn(blob, 'ft-anim -bottom-1/4 left-[30%] h-[70%] w-[45%]')} style={{ background: a, animation: anim('ft-blob-b', 19) }} />
        <div className={cn(blob, 'ft-anim -bottom-1/3 right-[-10%] h-[85%] w-[50%]')} style={{ background: b, animation: anim('ft-blob-c', 23) }} />
        <div className={cn(blob, 'ft-anim bottom-[10%] left-[55%] h-[35%] w-[25%] opacity-70')} style={{ background: c, animation: anim('ft-blob-a', 13) }} />
        <div className="absolute inset-x-0 top-0 h-2/3 bg-linear-to-b from-(--ft-bg) via-(--ft-bg)/80 to-transparent" />
      </div>
      {grain && <div aria-hidden className="pointer-events-none absolute inset-0 -z-10 opacity-[0.16] mix-blend-overlay" style={{ backgroundImage: NOISE }} />}
      <div className="mx-auto max-w-6xl px-6 pt-16 md:px-10 md:pt-20">
        <div className="grid gap-10 md:grid-cols-[1fr_2fr]">
          <div className="flex flex-col items-start gap-4">
            <Brand brand={brand} />
            <p className="max-w-xs text-[14px] leading-relaxed text-(--ft-soft)">{tagline}</p>
            <a
              href="#"
              className="mt-2 inline-flex h-9 items-center rounded-full bg-(--ft-ink) px-4 text-[13px] font-medium text-(--ft-bg) transition-opacity hover:opacity-85"
            >
              Start building →
            </a>
          </div>
          <FooterColumns arrows />
        </div>
      </div>
      <p
        aria-hidden
        className="ft-anim mt-10 px-4 text-center font-display leading-[0.8] font-bold tracking-[-0.06em] text-transparent select-none"
        style={
          {
            fontSize: `clamp(3rem, ${Math.min(26, 100 / Math.max(3, brand.length * 0.62))}cqw, 22rem)`,
            backgroundImage: `linear-gradient(100deg, var(--ft-accent), ${a}, ${b}, ${c}, var(--ft-accent))`,
            backgroundSize: '300% 100%',
            WebkitBackgroundClip: 'text',
            backgroundClip: 'text',
            animation: anim('ft-pan', 14),
            filter: `drop-shadow(0 0 ${24 * glow}px color-mix(in oklab, var(--ft-accent) 45%, transparent))`,
          } as CSSProperties
        }
      >
        {brand}
      </p>
      <div className="mx-auto max-w-6xl px-6 pt-6 pb-6 md:px-10">
        <BottomBar brand={brand} className="border-t border-(--ft-line) pt-5 [&_a]:text-(--ft-ink) [&_p]:text-(--ft-soft)" />
      </div>
    </FooterRoot>
  )
}
src/registry/footers/footer-kit.tsx
'use client'

import { useEffect, useRef, useState, type ComponentProps, type CSSProperties, type ReactNode, type RefObject } from 'react'
import { cn } from '@/lib/utils'

/**
 * Footer Kit: shared pieces behind the shinUI "Footers" blocks.
 *
 * Link columns, a socials row, a copyright line, a tiny placeholder mark,
 * light/dark palette variables, and the hooks the animated footers share:
 * reduced-motion and dark-mode detection plus a canvas loop that sizes itself
 * with layout (not transformed) pixels, pauses offscreen and cleans up.
 */

export type FooterLink = { label: string; href?: string; badge?: string }
export type FooterColumn = { title: string; links: FooterLink[] }

export const FOOTER_COLUMNS: FooterColumn[] = [
  {
    title: 'Product',
    links: [{ label: 'Overview' }, { label: 'Pricing' }, { label: 'Changelog' }, { label: 'Integrations', badge: 'New' }, { label: 'Roadmap' }],
  },
  {
    title: 'Developers',
    links: [{ label: 'Docs' }, { label: 'API reference' }, { label: 'CLI' }, { label: 'Examples' }, { label: 'Status' }],
  },
  {
    title: 'Company',
    links: [{ label: 'About' }, { label: 'Customers' }, { label: 'Careers' }, { label: 'Blog' }, { label: 'Press kit' }],
  },
  {
    title: 'Legal',
    links: [{ label: 'Privacy' }, { label: 'Terms' }, { label: 'Security' }, { label: 'Cookies' }],
  },
]

export const YEAR = new Date().getFullYear()

/** Light/dark palette. Pass `accent` to set --ft-accent. */
const VARS = [
  '[--ft-bg:#fbfbfa] [--ft-panel:#ffffff] [--ft-ink:#141414] [--ft-soft:rgb(20_20_20/0.62)] [--ft-faint:rgb(20_20_20/0.4)] [--ft-line:rgb(20_20_20/0.1)]',
  'dark:[--ft-bg:#0a0a0b] dark:[--ft-panel:#111113] dark:[--ft-ink:#f2f2f0] dark:[--ft-soft:rgb(242_242_240/0.62)] dark:[--ft-faint:rgb(242_242_240/0.38)] dark:[--ft-line:rgb(255_255_255/0.1)]',
].join(' ')

const KEYFRAMES = `
@keyframes ft-blink{0%,49%{opacity:1}50%,100%{opacity:0}}
@keyframes ft-marquee{from{transform:translateX(0)}to{transform:translateX(-50%)}}
@keyframes ft-drift{from{transform:translateX(-10%)}to{transform:translateX(110%)}}
@keyframes ft-pulse{0%{transform:scale(1);opacity:.7}100%{transform:scale(2.6);opacity:0}}
@media (prefers-reduced-motion:reduce){.ft-anim{animation:none!important}}
`

export interface FooterRootProps extends ComponentProps<'footer'> {
  accent?: string
}

/** <footer> with the palette, keyframes and an optional accent color. */
export function FooterRoot({ accent, className, style, children, ...props }: FooterRootProps) {
  return (
    <footer
      className={cn(VARS, '@container relative isolate overflow-hidden bg-(--ft-bg) font-sans text-(--ft-ink) antialiased', className)}
      style={{ ...(accent ? ({ '--ft-accent': accent } as CSSProperties) : null), ...style }}
      {...props}
    >
      <style>{KEYFRAMES}</style>
      {children}
    </footer>
  )
}

/** Pins a footer to the bottom of a preview so cards show its art, not empty space. */
export function FooterStage({ className, children }: { className?: string; children: ReactNode }) {
  return <div className={cn('flex min-h-0 flex-1 flex-col justify-end overflow-hidden [&>*]:shrink-0', className)}>{children}</div>
}

/** Placeholder mark: a quarter-circle in a rounded square. Swap in your own logo. */
export function FooterMark({ className }: { className?: string }) {
  return (
    <svg viewBox="0 0 24 24" aria-hidden className={cn('size-5 shrink-0', className)}>
      <rect x="1" y="1" width="22" height="22" rx="6" fill="currentColor" />
      <path d="M7 17V11a4 4 0 0 1 4-4h6" fill="none" stroke="var(--ft-bg)" strokeWidth="2.6" strokeLinecap="round" />
    </svg>
  )
}

export function Brand({ brand, className }: { brand: string; className?: string }) {
  return (
    <a href="#" className={cn('inline-flex items-center gap-2 font-display text-[17px] font-semibold tracking-[-0.02em]', className)}>
      <FooterMark className="text-(--ft-accent,currentColor)" />
      {brand}
    </a>
  )
}

export interface FooterColumnsProps {
  columns?: FooterColumn[]
  className?: string
  headingClassName?: string
  linkClassName?: string
  /** Show a ↗ that slides in on hover. */
  arrows?: boolean
}

/** Link columns: 2 across on phones, one per column from md up. */
export function FooterColumns({ columns = FOOTER_COLUMNS, className, headingClassName, linkClassName, arrows }: FooterColumnsProps) {
  return (
    <nav aria-label="Footer" className={cn('grid grid-cols-2 gap-x-6 gap-y-9 sm:grid-cols-4', className)}>
      {columns.map((col) => (
        <div key={col.title}>
          <p className={cn('text-[13px] font-medium text-(--ft-ink)', headingClassName)}>{col.title}</p>
          <ul className="mt-3.5 flex flex-col gap-2.5">
            {col.links.map((link) => (
              <li key={link.label}>
                <a
                  href={link.href ?? '#'}
                  className={cn('group/link inline-flex items-center gap-1.5 text-[13.5px] text-(--ft-soft) transition-colors hover:text-(--ft-ink)', linkClassName)}
                >
                  {link.label}
                  {link.badge && (
                    <span className="rounded-full border border-(--ft-line) px-1.5 py-px text-[10px] leading-4 text-(--ft-faint)">{link.badge}</span>
                  )}
                  {arrows && (
                    <span aria-hidden className="-translate-x-1 opacity-0 transition-all group-hover/link:translate-x-0 group-hover/link:opacity-100">
                      ↗
                    </span>
                  )}
                </a>
              </li>
            ))}
          </ul>
        </div>
      ))}
    </nav>
  )
}

type SocialName = 'x' | 'github' | 'linkedin' | 'youtube' | 'rss'
const SOCIAL_LABEL: Record<SocialName, string> = { x: 'X', github: 'GitHub', linkedin: 'LinkedIn', youtube: 'YouTube', rss: 'RSS feed' }

/** Simple stroke icons, drawn for this kit. */
export function SocialIcon({ name, className }: { name: SocialName; className?: string }) {
  const p = { fill: 'none', stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round' } as const
  return (
    <svg viewBox="0 0 24 24" aria-hidden className={cn('size-4', className)}>
      {name === 'x' && (
        <g {...p}>
          <path d="M5 4l14 16M19 4L5 20" />
        </g>
      )}
      {name === 'github' && (
        <g {...p}>
          <path d="M9 19c-4 1.3-4-2-6-2.5M15 21v-3.4a3 3 0 0 0-.8-2.3c2.7-.3 5.5-1.3 5.5-6a4.7 4.7 0 0 0-1.3-3.2 4.3 4.3 0 0 0-.1-3.2s-1-.3-3.4 1.3a11.6 11.6 0 0 0-6 0C6.5 2.6 5.5 2.9 5.5 2.9a4.3 4.3 0 0 0-.1 3.2A4.7 4.7 0 0 0 4.1 9.3c0 4.6 2.8 5.7 5.5 6a3 3 0 0 0-.8 2.3V21" />
        </g>
      )}
      {name === 'linkedin' && (
        <g {...p}>
          <rect x="3" y="3" width="18" height="18" rx="3" />
          <path d="M8 10.5V17M8 7.2v.1M12 17v-6.5M12 13.3c0-1.7 1-2.8 2.4-2.8s2.1 1 2.1 2.8V17" />
        </g>
      )}
      {name === 'youtube' && (
        <g {...p}>
          <rect x="2.5" y="5.5" width="19" height="13" rx="4" />
          <path d="M10.5 9.5v5l4-2.5z" />
        </g>
      )}
      {name === 'rss' && (
        <g {...p}>
          <path d="M5 11a8 8 0 0 1 8 8M5 5a14 14 0 0 1 14 14" />
          <circle cx="6" cy="18" r="1" />
        </g>
      )}
    </svg>
  )
}

export function Socials({ className, itemClassName }: { className?: string; itemClassName?: string }) {
  return (
    <ul className={cn('flex items-center gap-1', className)}>
      {(Object.keys(SOCIAL_LABEL) as SocialName[]).map((name) => (
        <li key={name}>
          <a
            href="#"
            aria-label={SOCIAL_LABEL[name]}
            className={cn('grid size-8 place-items-center rounded-full text-(--ft-soft) transition-colors hover:bg-(--ft-line) hover:text-(--ft-ink)', itemClassName)}
          >
            <SocialIcon name={name} />
          </a>
        </li>
      ))}
    </ul>
  )
}

export function Copyright({ brand, className, children }: { brand: string; className?: string; children?: ReactNode }) {
  return (
    <p className={cn('text-[12.5px] text-(--ft-faint)', className)}>
      © {YEAR} {brand}, Inc. {children}
    </p>
  )
}

/** Bottom bar: copyright left, socials right; stacks on phones. */
export function BottomBar({ brand, className, children }: { brand: string; className?: string; children?: ReactNode }) {
  return (
    <div className={cn('flex flex-col-reverse gap-4 sm:flex-row sm:items-center sm:justify-between', className)}>
      <Copyright brand={brand}>{children}</Copyright>
      <Socials className="-ml-2 sm:ml-0" />
    </div>
  )
}

/** Live `prefers-reduced-motion: reduce`. */
export function useReducedMotion() {
  const [reduced, setReduced] = useState(() => typeof window !== 'undefined' && window.matchMedia('(prefers-reduced-motion: reduce)').matches)
  useEffect(() => {
    const mq = window.matchMedia('(prefers-reduced-motion: reduce)')
    const on = () => setReduced(mq.matches)
    mq.addEventListener('change', on)
    return () => mq.removeEventListener('change', on)
  }, [])
  return reduced
}

/** Whether the element's document root has the `.dark` class (works inside the preview iframe too). */
export function useIsDark(ref: RefObject<Element | null>) {
  const [dark, setDark] = useState(false)
  useEffect(() => {
    const root = (ref.current?.ownerDocument ?? document).documentElement
    const read = () => setDark(root.classList.contains('dark'))
    read()
    const mo = new MutationObserver(read)
    mo.observe(root, { attributes: true, attributeFilter: ['class'] })
    return () => mo.disconnect()
  }, [ref])
  return dark
}

export interface CanvasFrame {
  ctx: CanvasRenderingContext2D
  /** CSS-pixel size of the canvas (layout size, unaffected by CSS transforms). */
  w: number
  h: number
  /** Seconds since start (frozen when not animating). */
  t: number
  /** Seconds since the previous frame. */
  dt: number
}

/**
 * Drive a 2D canvas: HiDPI sizing from offsetWidth/offsetHeight via ResizeObserver,
 * rAF while `animate` is on and the canvas is on screen, one still frame otherwise.
 * `draw` is read through a ref, so it can close over fresh props without restarting.
 */
export function useCanvasLoop(
  canvasRef: RefObject<HTMLCanvasElement | null>,
  draw: (frame: CanvasFrame) => void,
  { animate = true, fps = 60 }: { animate?: boolean; fps?: number } = {},
) {
  const drawRef = useRef(draw)
  useEffect(() => {
    drawRef.current = draw
  })
  const reduced = useReducedMotion()
  const running = animate && !reduced

  useEffect(() => {
    const canvas = canvasRef.current
    const ctx = canvas?.getContext('2d')
    if (!canvas || !ctx) return
    let w = 0
    let h = 0
    let raf = 0
    let visible = true
    let t = 0
    let last = performance.now()
    let acc = 0
    const step = 1 / fps

    const paint = (dt: number) => {
      if (!w || !h) return
      ctx.setTransform(canvas.width / w, 0, 0, canvas.height / h, 0, 0)
      drawRef.current({ ctx, w, h, t, dt })
    }
    const resize = () => {
      w = canvas.offsetWidth
      h = canvas.offsetHeight
      const dpr = Math.min(window.devicePixelRatio || 1, 2)
      canvas.width = Math.max(1, Math.round(w * dpr))
      canvas.height = Math.max(1, Math.round(h * dpr))
      paint(0)
    }
    const loop = (now: number) => {
      raf = requestAnimationFrame(loop)
      const dt = Math.min((now - last) / 1000, 0.1)
      last = now
      acc += dt
      if (acc < step * 0.9) return
      t += acc
      paint(acc)
      acc = 0
    }
    const start = () => {
      cancelAnimationFrame(raf)
      if (running && visible) {
        last = performance.now()
        raf = requestAnimationFrame(loop)
      }
    }
    const ro = new ResizeObserver(resize)
    ro.observe(canvas)
    const io = new IntersectionObserver(([entry]) => {
      visible = entry.isIntersecting
      start()
    })
    io.observe(canvas)
    resize()
    start()
    return () => {
      cancelAnimationFrame(raf)
      ro.disconnect()
      io.disconnect()
    }
  }, [canvasRef, running, fps])

  return running
}

/** Pointer position in the element's own (untransformed) pixels, or null when outside. */
export function usePointer(ref: RefObject<HTMLElement | null>) {
  const pointer = useRef<{ x: number; y: number; down: number } | null>(null)
  useEffect(() => {
    const el = ref.current
    if (!el) return
    const move = (e: PointerEvent) => {
      const r = el.getBoundingClientRect()
      const sx = el.offsetWidth / (r.width || 1)
      const sy = el.offsetHeight / (r.height || 1)
      pointer.current = { x: (e.clientX - r.left) * sx, y: (e.clientY - r.top) * sy, down: pointer.current?.down ?? 0 }
    }
    const leave = () => {
      pointer.current = null
    }
    el.addEventListener('pointermove', move)
    el.addEventListener('pointerdown', move)
    el.addEventListener('pointerleave', leave)
    return () => {
      el.removeEventListener('pointermove', move)
      el.removeEventListener('pointerdown', move)
      el.removeEventListener('pointerleave', leave)
    }
  }, [ref])
  return pointer
}

/**
 * Rasterize text to fill a w×h (CSS px) box and return a sampler: coverage 0..1 at (x, y) in CSS px.
 * Drawn at half resolution, which is plenty for dots and glyph cells.
 */
export function rasterizeText(
  text: string,
  w: number,
  h: number,
  { font = '800 100px "Space Grotesk", Inter, system-ui, sans-serif', fill = 0.92, align = 'center' as 'center' | 'bottom' } = {},
) {
  const k = 0.5
  const cw = Math.max(1, Math.round(w * k))
  const ch = Math.max(1, Math.round(h * k))
  const c = document.createElement('canvas')
  c.width = cw
  c.height = ch
  const ctx = c.getContext('2d', { willReadFrequently: true })
  if (!ctx || !text) return () => 0
  ctx.font = font
  const m = ctx.measureText(text)
  const asc = m.actualBoundingBoxAscent || 72
  const desc = m.actualBoundingBoxDescent || 0
  const left = m.actualBoundingBoxLeft || 0
  const tw = (m.actualBoundingBoxRight || m.width) + left || 1
  const scale = Math.min((cw * fill) / tw, (ch * fill) / (asc + desc))
  const top = align === 'bottom' ? ch - (asc + desc) * scale - ch * 0.04 : (ch - (asc + desc) * scale) / 2
  ctx.setTransform(scale, 0, 0, scale, (cw - tw * scale) / 2 + left * scale, top + asc * scale)
  ctx.fillStyle = '#fff'
  ctx.fillText(text, 0, 0)
  const data = ctx.getImageData(0, 0, cw, ch).data
  return (x: number, y: number) => {
    const px = Math.floor(x * k)
    const py = Math.floor(y * k)
    if (px < 0 || py < 0 || px >= cw || py >= ch) return 0
    return data[(py * cw + px) * 4 + 3] / 255
  }
}
src/registry/components/button.tsx
'use client'

import type { ComponentProps } from 'react'
import { cn } from '@/lib/utils'

const variants = {
  primary:
    'bg-ds-primary text-ds-primary-foreground shadow-[0_0_0_1px_rgb(255_255_255/0.12)_inset,0_8px_24px_-8px_var(--ds-primary)] hover:bg-ds-primary-hover',
  secondary: 'border border-border bg-ds-surface text-foreground hover:bg-ds-surface-hover',
  ghost: 'text-foreground hover:bg-ds-surface',
} as const

const sizes = {
  sm: 'h-8 gap-1.5 rounded-sm px-3 text-xs',
  md: 'h-10 gap-2 rounded-md px-4 text-sm',
  lg: 'h-12 gap-2.5 rounded-lg px-6 text-base',
} as const

export interface ButtonProps extends ComponentProps<'button'> {
  variant?: keyof typeof variants
  size?: keyof typeof sizes
}

export function Button({ className, variant = 'primary', size = 'md', type = 'button', ...props }: ButtonProps) {
  return (
    <button
      type={type}
      className={cn(
        'inline-flex shrink-0 cursor-pointer items-center justify-center font-medium whitespace-nowrap transition-all duration-150 select-none',
        'focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none',
        'active:scale-[0.97] disabled:pointer-events-none disabled:opacity-50',
        variants[variant],
        sizes[size],
        className,
      )}
      {...props}
    />
  )
}
src/registry/backgrounds/aurora.tsx
"use client";

import type { ComponentProps, CSSProperties } from "react";

import { cn } from "@/lib/utils";

/**
 * Keyframes ship with the component so the file works on its own. React 19
 * hoists a <style> with `href` + `precedence` into <head> once, however many
 * instances render.
 */
const AURORA_CSS = `
@keyframes ds-aurora {
  0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); }
  33% { transform: translate(12%, 8%) scale(1.15) rotate(20deg); }
  66% { transform: translate(-10%, 12%) scale(0.92) rotate(-15deg); }
}
.ds-aurora-orb { animation: ds-aurora 18s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .ds-aurora-orb { animation: none; } }
`;

export interface AuroraProps extends ComponentProps<"div"> {
  /** How strong the glow is. */
  intensity?: "subtle" | "vivid";
  /** Show a faint grid on top of the glow. */
  grid?: boolean;
  /** Seconds for one full drift cycle. Lower is faster. */
  speed?: number;
  /**
   * Softness of the glow (how far the haze reaches).
   * Softness comes from gradient falloff + circular masks, not `filter: blur()`,
   * which softens Chrome but turns into hard rotated discs in Edge.
   */
  blur?: number;
  colorA?: string;
  colorB?: string;
  colorC?: string;
}

/** Soft drifting aurora glow. Put any content inside it as children. */
export function Aurora({
  className,
  children,
  intensity = "vivid",
  grid = true,
  speed = 18,
  blur = 110,
  colorA = "var(--ds-primary, oklch(0.57 0.22 285))",
  colorB = "var(--ds-accent, oklch(0.66 0.13 205))",
  colorC = "var(--ds-highlight, oklch(0.63 0.21 350))",
  ...props
}: AuroraProps) {
  // Fully transparent well before the circle edge so rotation never shows a hard rim.
  const fadeEnd = Math.min(70, Math.max(48, Math.round(42 + blur * 0.2)));

  const orb = (color: string, delay: number): CSSProperties => ({
    background: `radial-gradient(circle at 50% 50%, ${color} 0%, ${color} 8%, transparent ${fadeEnd}%)`,
    animationDuration: `${speed}s`,
    animationDelay: `${-speed * delay}s`,
  });

  return (
    <div className={cn("relative isolate overflow-hidden bg-background", className)} {...props}>
      <style href="ds-aurora" precedence="default">
        {AURORA_CSS}
      </style>
      <div
        aria-hidden
        className={cn(
          "pointer-events-none absolute inset-0 -z-10",
          intensity === "subtle" ? "opacity-45" : "opacity-85"
        )}
      >
        {/*
          Circles (rounded-full), not rectangles. The animation rotates each
          orb; a rotated rect shows hard corners in Edge. A circle stays soft
          under rotation when the gradient fades out early.
        */}
        <div
          className="ds-aurora-orb absolute -top-[35%] -left-[30%] aspect-square w-[110%] rounded-full"
          style={orb(colorA, 0)}
        />
        <div
          className="ds-aurora-orb absolute -top-[25%] -right-[35%] aspect-square w-[100%] rounded-full"
          style={orb(colorB, 1 / 3)}
        />
        <div
          className="ds-aurora-orb absolute -bottom-[45%] left-[0%] aspect-square w-[105%] rounded-full"
          style={orb(colorC, 2 / 3)}
        />
        {grid && (
          <div
            className="absolute inset-0 mask-[radial-gradient(ellipse_at_center,black_30%,transparent_75%)] bg-size-[48px_48px]"
            style={{
              backgroundImage:
                "linear-gradient(to right, color-mix(in oklab, var(--color-foreground) 7%, transparent) 1px, transparent 1px), linear-gradient(to bottom, color-mix(in oklab, var(--color-foreground) 7%, transparent) 1px, transparent 1px)",
            }}
          />
        )}
        <div className="absolute inset-0 bg-[radial-gradient(ellipse_at_center,transparent_10%,var(--color-background)_82%)]" />
      </div>
      {children}
    </div>
  );
}
src/registry/backgrounds/horizon-beam.tsx
"use client";

import type { ComponentProps, CSSProperties } from "react";

import { cn } from "@/lib/utils";

/** Keyframes ship with the component; React 19 hoists this <style> once. */
const HORIZON_CSS = `
@keyframes ds-horizon {
  0%, 100% { transform: translateX(-6%) scaleX(1); opacity: 0.55; }
  50% { transform: translateX(6%) scaleX(1.08); opacity: 1; }
}
.ds-horizon-beam { animation: ds-horizon 9s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .ds-horizon-beam { animation: none; } }
`;

export interface HorizonBeamProps extends ComponentProps<"div"> {
  /** Beam color. */
  color?: string;
  /** Vertical position of the horizon line (0 to 100). */
  altitude?: number;
  /** Beam thickness feel. */
  thickness?: "thin" | "medium" | "wide";
  /** Seconds for one breath cycle. */
  speed?: number;
}

const thicknessMap = {
  thin: "h-px",
  medium: "h-0.5",
  wide: "h-1",
} as const;

/** A breathing light beam on a horizon: spare, graphic, Edge-safe. */
export function HorizonBeam({
  className,
  children,
  color = "var(--ds-accent, oklch(0.66 0.13 205))",
  altitude = 58,
  thickness = "medium",
  speed = 9,
  ...props
}: HorizonBeamProps) {
  const y = Math.min(90, Math.max(10, altitude));

  const glow: CSSProperties = {
    background: `linear-gradient(90deg, transparent 0%, ${color} 35%, ${color} 65%, transparent 100%)`,
    boxShadow: `0 0 48px 4px color-mix(in oklab, ${color} 55%, transparent), 0 0 120px 20px color-mix(in oklab, ${color} 22%, transparent)`,
    animationDuration: `${speed}s`,
  };

  const sky: CSSProperties = {
    background: `linear-gradient(180deg, var(--color-background) 0%, color-mix(in oklab, ${color} 12%, var(--color-background)) ${y}%, var(--color-background) 100%)`,
  };

  return (
    <div className={cn("relative isolate overflow-hidden bg-background", className)} {...props}>
      <style href="ds-horizon-beam" precedence="default">
        {HORIZON_CSS}
      </style>
      <div aria-hidden className="pointer-events-none absolute inset-0 -z-10">
        <div className="absolute inset-0" style={sky} />
        <div
          className={cn("ds-horizon-beam absolute left-[-10%] w-[120%]", thicknessMap[thickness])}
          style={{ top: `${y}%`, ...glow }}
        />
        <div
          className="absolute inset-x-0 bottom-0 h-1/2 opacity-40"
          style={{
            background: `linear-gradient(180deg, transparent, color-mix(in oklab, ${color} 8%, transparent))`,
            maskImage: "linear-gradient(90deg, transparent, black 20%, black 80%, transparent)",
          }}
        />
      </div>
      {children}
    </div>
  );
}

More in Blocks