Interactive Card
shadcn-glass-ui/interactive-cardFreeUtility
Unified wrapper for card components with hover animations and glass effects. * Eliminates hover state duplication in MetricCardGlass, YearCardGlass, * AICardGlass, RepositoryCardGlass, and other card components. * * Features:
Install it
npx shadcn@latest add https://raw.githubusercontent.com/artyhoo/shadcn-glass-ui-library/main/public/r/interactive-card.jsonSource
1/**2 * InteractiveCard Component3 *4 * Unified wrapper for card components with hover animations and glass effects.5 * Eliminates hover state duplication in MetricCardGlass, YearCardGlass,6 * AICardGlass, RepositoryCardGlass, and other card components.7 *8 * Features:9 * - Hover lift animation (translateY -2px)10 * - Optional glow effects11 * - Glass surface with backdrop blur12 * - Configurable backgrounds and borders13 */1415import { forwardRef, type HTMLAttributes, type CSSProperties } from 'react';16import { cn } from '@/lib/utils';17import { useHover } from '@/lib/hooks/use-hover';1819/**20 * Props for the InteractiveCard component21 */22export interface InteractiveCardProps extends HTMLAttributes<HTMLDivElement> {23 /**24 * Enable hover lift effect (translateY -2px)25 * @default true26 */27 hoverLift?: boolean;2829 /**30 * CSS variable for hover glow effect31 * @example 'var(--glow-primary)'32 */33 hoverGlow?: string;3435 /**36 * CSS variable for hover background37 * @example 'var(--card-hover-bg)'38 */39 hoverBg?: string;4041 /**42 * CSS variable for base background43 * @default 'var(--card-bg)'44 */45 baseBg?: string;4647 /**48 * CSS variable for border color49 * @default 'var(--card-border)'50 */51 borderColor?: string;5253 /**54 * CSS variable for hover border color55 */56 hoverBorderColor?: string;5758 /**59 * Blur level for glass effect60 * @default 'sm'61 */62 blur?: 'sm' | 'md' | 'lg' | 'xl';6364 /**65 * Disable all hover interactions66 * @default false67 */68 disabled?: boolean;6970 /**71 * Border radius class72 * @default 'rounded-2xl'73 */74 rounded?: 'rounded-xl' | 'rounded-2xl' | 'rounded-3xl';7576 /**77 * Transition speed78 * @default 'var(--transition-slow)'79 */80 transition?: string;81}8283/**84 * InteractiveCard component85 *86 * Provides consistent hover animations and glass effects for card components.87 * Replaces ~80 lines of duplicated hover state management across 4+ components.88 *89 * @example90 * ```tsx91 * // Basic usage92 * <InteractiveCard>93 * <h3>Card Title</h3>94 * <p>Card content</p>95 * </InteractiveCard>96 *97 * // With hover effects98 * <InteractiveCard99 * hoverLift100 * hoverGlow="var(--glow-primary)"101 * hoverBg="var(--card-hover-bg)"102 * hoverBorderColor="var(--card-hover-border)"103 * >104 * <MetricContent />105 * </InteractiveCard>106 *107 * // Custom blur and rounding108 * <InteractiveCard109 * blur="md"110 * rounded="rounded-3xl"111 * baseBg="var(--metric-success-bg)"112 * >113 * <StatusCard />114 * </InteractiveCard>115// … truncated
More from shadcn-glass-ui
All 76 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Form Field Wrapperform-field-wrapper | shadcn-glass-ui | Utilities | Free | no deps | |
| Touch Targettouch-target | shadcn-glass-ui | Utilities | Free | no deps |
