Componentdata1.27 KB gzipZero dependencies
Spotlight
Full-viewport dim overlay with cutout hole positioned via target ref/bounding box; pulse ring around target; caption card.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add spotlightOr install the full npm package:
npm install bigbulluiUsage
tsx4 lines
import { Spotlight } from "@/components/ui/spotlight" const ref = React.useRef<HTMLDivElement>(null);<Spotlight targetRef={ref} padding={24} title="Feature" description="Highlighted area" />Source code
spotlight.tsx + 2 helpersZero third-party dependencies (3 local files shown in tabs below).
tsxspotlight.tsx141 lines
"use client"; import * as React from "react";import { getFocusable, lockBodyScroll, registerEscapeLayer, trapFocus } from "./lib/focus-trap";import { cn } from "./lib/utils"; export type SpotlightProps = { targetRef: React.RefObject<HTMLElement | null>; padding?: number; title?: string; description?: string;} & Omit<React.HTMLAttributes<HTMLElement>, "title">; export function Spotlight({ targetRef, padding = 24, title, description, ...props }: SpotlightProps) { const [visible, setVisible] = React.useState(false); const [targetBox, setTargetBox] = React.useState({ left: 0, top: 0, width: 0, height: 0 }); const overlayRef = React.useRef<HTMLDivElement>(null); const restoreRef = React.useRef<HTMLElement | null>(null);Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { Spotlight } from "@/components/ui/spotlight"; <Spotlight />| Prop | Type | Description |
|---|---|---|
| targetRef | React.RefObject<HTMLElement | null> | Ref to the element to highlight. |
| padding | number | Padding around the highlighted element. |
| title | string | Optional title text in the caption card. |
| description | string | Optional description text in the caption card. |