diff --git a/src/components/ui/ShareButton.tsx b/src/components/ui/ShareButton.tsx
new file mode 100644
index 0000000..b6f6c2b
--- /dev/null
+++ b/src/components/ui/ShareButton.tsx
@@ -0,0 +1,149 @@
+"use client";
+
+import React, { useState, useEffect } from 'react';
+import { motion, AnimatePresence } from 'framer-motion';
+import { Share2, Check } from 'lucide-react';
+import styles from './Button.module.css';
+
+interface ShareButtonProps {
+ url?: string;
+ title?: string;
+ text?: string;
+ className?: string;
+ variant?: 'primary' | 'secondary' | 'ghost';
+ label?: string;
+ showLabel?: boolean;
+}
+
+export default function ShareButton({
+ url,
+ title,
+ text,
+ className = '',
+ variant = 'secondary',
+ label = 'Share',
+ showLabel = true,
+}: ShareButtonProps) {
+ const [copied, setCopied] = useState(false);
+ const [isMobileShareSupported, setIsMobileShareSupported] = useState(false);
+
+ useEffect(() => {
+ // Detect native mobile/browser share support safely on mount
+ if (typeof navigator !== 'undefined' && typeof navigator.share === 'function') {
+ setIsMobileShareSupported(true);
+ }
+ }, []);
+
+ const handleShare = async (e: React.MouseEvent) => {
+ e.stopPropagation(); // Avoid triggering any card click events
+
+ const shareUrl = url || (typeof window !== 'undefined' ? window.location.href : '');
+ const shareTitle = title || (typeof document !== 'undefined' ? document.title : 'DevPath');
+ const shareText = text || 'Check out this learning path on DevPath!';
+
+ if (isMobileShareSupported) {
+ try {
+ await navigator.share({
+ title: shareTitle,
+ text: shareText,
+ url: shareUrl,
+ });
+ } catch (error) {
+ // If sharing was aborted or failed, ignore it
+ console.warn('Native share cancelled or failed:', error);
+ }
+ } else {
+ // Desktop fallback: copy to clipboard
+ try {
+ await navigator.clipboard.writeText(shareUrl);
+ setCopied(true);
+ setTimeout(() => setCopied(false), 2000);
+ } catch (err) {
+ console.error('Failed to copy to clipboard:', err);
+ }
+ }
+ };
+
+ return (
+
+
+
+
+
+ {copied ? (
+
+
+
+ ) : (
+
+
+
+ )}
+
+
+ {showLabel && (
+
+ {copied ? 'Copied!' : label}
+
+ )}
+
+
+ {/* Hover shine effect */}
+
+
+ {/* Dynamic background glow on copy */}
+
+
+
+ {/* Custom toast/tooltip popover for desktop users on copy fallback */}
+
+ {copied && !isMobileShareSupported && (
+
+
+ Copied to Clipboard!
+
+ )}
+
+
+ );
+}