hover-preview
jolyui-ui/hover-previewFreeComponent
jolyui/ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by jolyui/ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://jolyui.dev/r/hover-preview.jsonSource
1"use client";23import NextImage from "next/image";4import type React from "react";5import {6 createContext,7 forwardRef,8 useCallback,9 useContext,10 useEffect,11 useRef,12 useState,13} from "react";14import { cn } from "@/lib/cn";1516// ==========================================17// TYPES & INTERFACES18// ==========================================1920export interface PreviewData {21 /** Image URL for the preview card */22 image: string;23 /** Title displayed in the preview card */24 title: string;25 /** Subtitle or description displayed below the title */26 subtitle?: string;27}2829export interface HoverPreviewLinkProps {30 /** Unique key to identify which preview data to show */31 previewKey: string;32 /** Content to render as the hoverable link */33 children: React.ReactNode;34 /** Additional CSS classes for the link */35 className?: string;36}3738export interface HoverPreviewCardProps {39 /** Width of the preview card in pixels */40 width?: number;41 /** Border radius of the card */42 borderRadius?: number;43 /** Additional CSS classes for the card */44 className?: string;45}4647export interface HoverPreviewProviderProps {48 /** Preview data object with keys matching the previewKey in HoverPreviewLink */49 data: Record<string, PreviewData>;50 /** Children components (should include HoverPreviewLink components) */51 children: React.ReactNode;52 /** Card configuration options */53 cardProps?: HoverPreviewCardProps;54 /** Offset distance from cursor in pixels */55 cursorOffset?: number;56 /** Whether to preload all images on mount */57 preloadImages?: boolean;58 /** Additional CSS classes for the container */59 className?: string;60}6162// ==========================================63// CONTEXT64// ==========================================6566interface HoverPreviewContextValue {67 data: Record<string, PreviewData>;68 activePreview: PreviewData | null;69 position: { x: number; y: number };70 isVisible: boolean;71 cardProps: HoverPreviewCardProps;72 handleHoverStart: (key: string, e: React.MouseEvent) => void;73 handleHoverMove: (e: React.MouseEvent) => void;74 handleHoverEnd: () => void;75}7677const HoverPreviewContext = createContext<HoverPreviewContextValue | null>(78 null,79);8081function useHoverPreview() {82 const context = useContext(HoverPreviewContext);83 if (!context) {84 throw new Error(85 "HoverPreviewLink must be used within a HoverPreviewProvider",86 );87 }88 return context;89}9091// ==========================================92// COMPONENTS93// … truncated
Files it writes
More from jolyui/ui
All 199 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ai-prompt-boxai-prompt-box | jolyui/ui | Components | Free | 4 deps | |
| animated-beamanimated-beam | jolyui/ui | Components | Free | 1 dep | |
| animated-tableanimated-table | jolyui/ui | Components | Free | 2 deps | |
| animated-theme-toggleanimated-theme-toggle | jolyui/ui | Components | Free | 2 deps | |
| animated-toastanimated-toast | jolyui/ui | Components | Free | 2 deps | |
| animated-tooltipanimated-tooltip | jolyui/ui | Components | Free | 1 dep | |
| bento-gridbento-grid | jolyui/ui | Components | Free | no deps | |
| buttonbutton | jolyui/ui | Components | Free | 3 deps |
