Glow

The soft blurred background glow from the three glow tokens, with an optional dot grid.

Glow sits behind the hero media.

Install

$ npx shadcn@latest add @nudgekit/glow

Or with no config: npx shadcn@latest add https://ui.nudgekit.app/r/glow.json

Usage

usage.tsx
import { Glow } from "@/components/glow"

<section className="relative overflow-hidden">
  <Glow dots />
  <div className="relative">…</div>
</section>

Do

  • Use behind the hero and once in the closing CTA panel.

Don't

  • Use it behind body sections or cards.
  • Change the glow colours per section.

Code

What the CLI writes into your project. It is yours to change.

components/glow.tsx
import * as React from "react";

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

export interface GlowProps extends React.HTMLAttributes<HTMLDivElement> {
  /** Where the glow sits. Hero glows go top-right, behind the media. */
  position?: "top-right" | "top-left" | "center";
  /** Adds a faint dot grid under the glow. */
  dots?: boolean;
}

const positions = {
  "top-right": "-right-[120px] -top-[60px]",
  "top-left": "-left-[120px] -top-[60px]",
  center: "left-1/2 top-0 -translate-x-1/2",
};

/**
 * The soft blurred background glow made from the three glow tokens.
 * Place it as the first child of a `relative overflow-hidden` section.
 */
function Glow({ position = "top-right", dots = false, className, ...props }: GlowProps) {
  return (
    <div aria-hidden data-slot="glow" className={cn("pointer-events-none absolute inset-0 -z-0", className)} {...props}>
      <div
        className={cn("absolute h-[620px] w-[820px] max-w-none opacity-75 blur-[60px]", positions[position])}
        style={{
          background:
            "radial-gradient(closest-side at 35% 40%, var(--glow-1), transparent), radial-gradient(closest-side at 70% 30%, var(--glow-2), transparent), radial-gradient(closest-side at 60% 75%, var(--glow-3), transparent)",
        }}
      />
      {dots && (
        <div
          className="absolute inset-0 opacity-55"
          style={{
            backgroundImage: "radial-gradient(rgb(11 31 51 / 0.14) 1px, transparent 1px)",
            backgroundSize: "22px 22px",
            maskImage: "radial-gradient(ellipse 42% 60% at 76% 52%, #000, transparent 72%)",
            WebkitMaskImage: "radial-gradient(ellipse 42% 60% at 76% 52%, #000, transparent 72%)",
          }}
        />
      )}
    </div>
  );
}

export { Glow };