### Install Spotlight via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/spotlight/page.mdx Instructions for installing the spotlight component using the command-line interface. This is the recommended method for quick setup. ```bash npx --yes @motion-primitives/cli@latest spotlight ``` -------------------------------- ### Install Image Comparison via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/image-comparison/page.mdx Installs the image-comparison package using the command-line interface. This is the recommended method for quick setup. ```bash ``` -------------------------------- ### Install In View Component via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/in-view/page.mdx Provides the command to install the In View component using the CLI. This is the recommended method for quick setup. ```bash npx shadcn add "https://motion-primitives.com/c/in-view.json" ``` -------------------------------- ### Install Scroll Progress via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/scroll-progress/page.mdx Instructions for installing the scroll-progress package using the command-line interface. This is the recommended method for quick setup. ```bash npm install @motion-primitives/scroll-progress # or yarn add @motion-primitives/scroll-progress # or pnpm add @motion-primitives/scroll-progress ``` -------------------------------- ### Example: Add Text Morph Component Source: https://github.com/ibelick/motion-primitives/blob/main/cli/README.md Demonstrates adding the 'text-morph' component. The CLI will automatically install necessary dependencies. ```bash npx motion-primitives add text-morph ``` -------------------------------- ### Install Dock via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/dock/page.mdx Use the CLI to install the dock component into your project. ```bash npx motion-primitives install dock ``` -------------------------------- ### Install Animated Number via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/animated-number/page.mdx Use this command to install the Animated Number component using the CLI. This is the recommended installation method for quick setup. ```bash npm install animated-number ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/ibelick/motion-primitives/blob/main/CONTRIBUTING.md Install all necessary project dependencies using npm. ```bash npm install ``` -------------------------------- ### Install Carousel CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/carousel/page.mdx Use the CLI to install the carousel component. This is the recommended installation method. ```bash npx motion-primitives@latest install carousel ``` -------------------------------- ### Install Transition Panel via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/transition-panel/page.mdx Provides the command to install the transition-panel package using the CLI. ```bash npm install @motion-primitives/transition-panel # or yarn add @motion-primitives/transition-panel ``` -------------------------------- ### Install Disclosure via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/disclosure/page.mdx Instructions for installing the Disclosure component using the command-line interface. ```bash npx motion-primitives install disclosure ``` -------------------------------- ### Install Text Scramble via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-scramble/page.mdx Provides the command to install the text-scramble package using the command-line interface. This is the recommended method for quick setup. ```bash npm install @motion-primitives/text-scramble ``` -------------------------------- ### Install Lucide React Icons Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/installation/page.mdx Install the Lucide React library to use icons within your project. ```bash npm install lucide-react ``` -------------------------------- ### Dialog Component Installation (Manual) Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/dialog/page.mdx Copy and paste this code into your project for manual installation. Remember to update import paths. ```typescript import Dialog from "components/core/dialog"; // Usage example: Open Dialog Dialog Title This is the dialog description. Close ``` -------------------------------- ### Install Glow Effect via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/glow-effect/page.mdx Command to install the glow-effect package using the CLI. ```bash npx motion-primitives@latest install glow-effect ``` -------------------------------- ### Install Spinning Text via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/spinning-text/page.mdx Use this command to install the spinning-text package using the CLI. ```bash npx motion-primitives install spinning-text ``` -------------------------------- ### Install Text Shimmer Wave via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-shimmer-wave/page.mdx Installs the text shimmer wave component using the command-line interface. Use the 'text-shimmer-wave' argument. ```bash ``` -------------------------------- ### Install Motion Package Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/installation/page.mdx Use npm to install the Motion package, which is used for component animations. ```bash npm install motion ``` -------------------------------- ### Install Motion Primitives CLI Globally Source: https://github.com/ibelick/motion-primitives/blob/main/cli/README.md Install the CLI globally to use commands directly from your terminal. ```bash npm install -g motion-primitives motion-primitives ``` -------------------------------- ### Basic Text Roll Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-roll/page.mdx Demonstrates the default usage of the Text Roll component for simple text animations. No specific setup is required beyond importing the component. ```tsx import { TextRollBasic } from './text-roll-basic'; // Usage: ``` -------------------------------- ### Install Text Loop via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-loop/page.mdx Provides the command to install the Text Loop component using the command-line interface. ```bash npm install @motion-primitives/text-loop # or yarn add @motion-primitives/text-loop # or pnpm add @motion-primitives/text-loop ``` -------------------------------- ### Manual Installation of Dock Component Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/dock/page.mdx Copy and paste the provided code into your project for manual installation. Remember to update import paths as needed. ```typescript import { motion } from 'framer-motion'; export function Dock({ children, className, spring = { mass: 0.1, stiffness: 150, damping: 12 }, magnification = 80, distance = 150, panelHeight = 64, }: DockProps) { const variants: Variants = { visible: { opacity: 1, transition: { when: 'beforeChildren', staggerChildren: 0.05, }, }, hidden: { opacity: 0, transition: { when: 'afterChildren', staggerChildren: 0.05, }, }, }; return ( {children} ); } export interface DockProps { children: React.ReactNode; className?: string; spring?: SpringOptions; magnification?: number; distance?: number; panelHeight?: number; } const DockProvider = ({ children, spring, magnification, distance }: DockProps) => { const [hovered, setHovered] = React.useState(null); return ( {children} ); }; const DockContext = React.createContext void }>({ hovered: null, setHovered: () => {}, spring: { mass: 0.1, stiffness: 150, damping: 12 }, magnification: 80, distance: 150, }); export const useDock = () => React.useContext(DockContext); ``` -------------------------------- ### Tilt Component Installation (Manual) Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/tilt/page.mdx Copy and paste this code into your project to manually install the Tilt component. Remember to update import paths as needed. ```tsx import { motion } from 'framer-motion'; import { twMerge } from 'tailwind-merge'; import { SpringOptions, useSpring } from 'framer-motion'; interface TiltProps extends React.HTMLAttributes { children: React.ReactNode; className?: string; style?: React.CSSProperties; rotationFactor?: number; isRevese?: boolean; springOptions?: SpringOptions; } export const Tilt = ({ children, className, style, rotationFactor = 15, isRevese = false, springOptions, ...props }: TiltProps) => { const [{ rotateX, rotateY }, api] = useSpring(() => ({ rotateX: 0, rotateY: 0 }), { ...springOptions, }); const handleMouseMove = (e: React.MouseEvent) => { const rect = (e.target as HTMLDivElement).getBoundingClientRect(); const x = e.clientX - rect.left; const y = e.clientY - rect.top; const centerX = rect.width / 2; const centerY = rect.height / 2; const rotateX = ((y - centerY) / centerY) * rotationFactor * (isRevese ? -1 : 1); const rotateY = ((x - centerX) / centerX) * rotationFactor * (isRevese ? -1 : 1); api.start({ rotateX, rotateY }); }; const handleMouseLeave = () => { api.start({ rotateX: 0, rotateY: 0 }); }; return ( {children} ); }; ``` -------------------------------- ### Accordion Installation (Manual) Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/accordion/page.mdx Provides the code to be copied and pasted for manual installation of the Accordion component. ```tsx import { Accordion } from 'components/core/accordion'; // Example usage: Is it accessible? Yes. It adheres to the WAI-ARIA design pattern. Is it customizable? Yes. It supports custom styles and animations. ``` -------------------------------- ### Install Transition Panel Manually Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/transition-panel/page.mdx Shows the code to copy and paste for manual installation of the Transition Panel component. ```tsx import { Transition } from 'motion'; interface TransitionPanelProps extends MotionProps { children: React.ReactNode[]; className?: string; transition?: Transition; activeIndex?: number; variants?: { enter: { opacity: number; x: number; }; center: { opacity: number; x: number; }; exit: { opacity: number; x: number; }; }; } export const TransitionPanel = ({ children, className, transition, activeIndex = 0, variants, ...motionProps }: TransitionPanelProps) => { return (
{children.map((child, index) => ( {child} ))}
); }; ``` -------------------------------- ### Install Sliding Number via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/sliding-number/page.mdx Use this command to install the sliding-number package using the CLI. ```bash npx install-peerdeps --save sliding-number ``` -------------------------------- ### Tabs with Transition Panel Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/transition-panel/page.mdx Demonstrates how to use the Transition Panel with tabs for managing different content views. ```tsx import { TabsTransitionPanel } from './transition-panel-tabs'; import ComponentCodePreview from '@/components/website/component-code-preview'; // ... other imports and component logic } filePath='app/docs/transition-panel/transition-panel-tabs.tsx' /> ``` -------------------------------- ### Animated Background Component Installation Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/animated-background/page.mdx Copy and paste this code into your project to install the Animated Background component. Update import paths as needed. ```tsx import { motion } from 'framer-motion'; import { useState, Children, cloneElement } from 'react'; interface AnimatedBackgroundProps { children: React.ReactNode; defaultValue?: string; onValueChange?: (newActiveId: string | null) => void; className?: string; transition?: object; enableHover?: boolean; } export function AnimatedBackground({ children, defaultValue, onValueChange, className, transition, enableHover, }: AnimatedBackgroundProps) { const [activeId, setActiveId] = useState(defaultValue || null); const handleItemClick = (id: string) => { setActiveId(id); onValueChange?.(id); }; const handleItemHoverStart = (id: string) => { if (enableHover) { setActiveId(id); } }; const handleItemHoverEnd = () => { if (enableHover && defaultValue) { setActiveId(defaultValue); } else if (enableHover) { setActiveId(null); } }; const items = Children.map(children, (child) => { if (React.isValidElement(child)) { const id = child.props?.['data-id']; if (!id) { console.warn('Each child must have a unique `data-id` attribute.'); return child; } return cloneElement(child, { onClick: () => handleItemClick(id), onHoverStart: () => handleItemHoverStart(id), onHoverEnd: handleItemHoverEnd, 'data-active': activeId === id, }); } return child; }); return (
{items}
); } ``` -------------------------------- ### Install Disclosure Manually Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/disclosure/page.mdx Provides the code snippet for manual installation of the Disclosure component. ```tsx import { Steps, Step } from '@motion-primitives/core'; import CodeBlock from '@/components/website/code-block'; // ... Copy and paste the following code into your project. Update the import paths to match your project setup. ``` -------------------------------- ### Manual Installation of Text Effect Component Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-effect/page.mdx Copy this code into your project for manual installation. Remember to update import paths as needed. ```typescript import { TextEffect } from "@/components/core/text-effect"; export default function Page() { return ( This is a text effect. ); } ``` -------------------------------- ### Magnetic Component Installation Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/magnetic/page.mdx Install the Magnetic component using the CLI or manually by copying the provided code. Ensure import paths are updated. ```tsx import { Magnetic } from '@motion-primitives/core/magnetic'; function MyComponent() { return (
Hover over me
); } ``` -------------------------------- ### Progressive Blur Basic Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/progressive-blur/page.mdx Demonstrates the basic implementation of the Progressive Blur component. ```tsx import { ProgressiveBlurBasic } from './progressive-blur-basic'; function App() { return ( ); } ``` -------------------------------- ### Manual Installation of Image Comparison Component Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/image-comparison/page.mdx Provides the code snippet for manual installation of the image comparison component. Copy this code into your project and adjust import paths as needed. ```tsx import { Steps, Step, CodeBlock } from '@components/documentation'; // ... Copy and paste the following code into your project. Update the import paths to match your project setup. ``` -------------------------------- ### Install Morphing Popover via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/morphing-popover/page.mdx Installs the morphing-popover component using the command-line interface. This is a quick way to add the component to your project. ```bash npx --yes motion-primitives@latest install morphing-popover ``` -------------------------------- ### Install Infinite Slider via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/infinite-slider/page.mdx Provides the command to install the infinite-slider package using the CLI. Ensure you have the CLI tool set up in your project. ```bash npm install infinite-slider ``` -------------------------------- ### Progressive Blur Component Installation Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/progressive-blur/page.mdx Provides the code to install the Progressive Blur component manually by copying and pasting into your project. ```tsx import { ProgressiveBlur } from '@/components/core/progressive-blur'; function App() { return ( ); } ``` -------------------------------- ### Manual Installation of Spotlight Component Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/spotlight/page.mdx Provides the code to manually integrate the spotlight component into your project. Ensure to update import paths as needed. ```tsx import { Spotlight } from './components/core/spotlight'; function App() { return ; } ``` -------------------------------- ### Scroll Progress Navigation Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/scroll-progress/page.mdx An example demonstrating scroll progress used for navigation. This snippet likely integrates scroll progress with navigation elements. ```tsx import { ScrollProgress } from '@/components/core/scroll-progress'; export function ScrollProgressBasic2() { return ( ); } ``` -------------------------------- ### Install Scroll Progress Manually Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/scroll-progress/page.mdx Manual installation steps for the scroll-progress component. This involves copying and pasting the component code directly into your project. ```tsx import { ScrollProgress } from '@/components/core/scroll-progress'; export function YourComponent() { return ( ); } ``` -------------------------------- ### Basic Dialog Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/dialog/page.mdx Demonstrates the basic usage of the Dialog component. This snippet shows how to render a simple dialog. ```typescript import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose, } from '@/components/ui/dialog'; export function DialogBasic() { return ( Edit profile Make changes to your profile here. Click save, when you're done.
); } ``` -------------------------------- ### Basic Carousel Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/carousel/page.mdx Demonstrates the basic implementation of the carousel component. ```typescript import { CarouselBasic } from './carousel-basic'; // Usage: ``` -------------------------------- ### Accordion Basic Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/accordion/page.mdx Demonstrates the basic usage of the Accordion component. ```tsx import { AccordionBasic } from './accordion-basic'; ``` -------------------------------- ### Install Text Scramble Manually Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-scramble/page.mdx Shows the manual installation process by copying and pasting the core text scramble component code into your project. Remember to update import paths as needed. ```typescript import { TextScramble } from '@/components/core/text-scramble'; // ... Hello World ``` -------------------------------- ### Manual Installation of Cursor Component Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/cursor/page.mdx Provides the code to manually install the cursor component. Copy this code into your project and update import paths as needed. ```tsx import { Cursor } from '@/components/core/cursor'; function App() { return ( {/* Your page content */} ); } ``` -------------------------------- ### Border Trail Component Installation Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/border-trail/page.mdx Copy and paste this code into your project to install the Border Trail component manually. Update import paths as needed. ```typescript import { motion } from 'framer-motion'; interface BorderTrailProps { className?: string; size?: number; transition?: any; onAnimationComplete?: () => void; } export const BorderTrail = ({ className, size = 60, transition, onAnimationComplete, }: BorderTrailProps) => { return (
); }; ``` -------------------------------- ### Manual Installation of Text Loop Component Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-loop/page.mdx Includes the core code for the Text Loop component that can be manually copied and pasted into a project. ```typescript import React from 'react'; import { motion, AnimatePresence } from 'framer-motion'; interface Variants { [key: string]: React.CSSProperties; } interface Transition { duration: number; ease: string; } interface TextLoopProps { children: React.ReactNode[]; className?: string; interval?: number; transition?: Transition; variants?: Variants; onIndexChange?: (index: number) => void; trigger?: boolean; mode?: 'wait' | 'sync' | 'pop' | 'waitChildren' | 'syncChild('/'); } export const TextLoop: React.FC = ({ children, className, interval = 2, transition = { duration: 0.5, ease: 'easeInOut' }, variants, onIndexChange, trigger = true, mode = 'popLayout', }) => { const [index, setIndex] = React.useState(0); React.useEffect(() => { if (trigger) { const timer = setInterval(() => { setIndex((prevIndex) => { const nextIndex = (prevIndex + 1) % children.length; if (onIndexChange) { onIndexChange(nextIndex); } return nextIndex; }); }, interval * 1000); return () => clearInterval(timer); } }, [interval, trigger, children.length, onIndexChange]); const currentChild = children[index]; return (
{currentChild}
); }; ``` -------------------------------- ### Cursor with Image and Spring (Alternative) Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/cursor/page.mdx Another example showcasing a cursor with an image and spring animations, using the Cursor3 component. ```tsx import { Cursor3 } from './cursor-3'; // ... } filePath='app/docs/cursor/cursor-3.tsx' /> ``` -------------------------------- ### Install Text Roll via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-roll/page.mdx Provides the command to install the Text Roll component using the command-line interface. This is the recommended method for quick integration. ```bash npm install @motion-primitives/text-roll # or yarn add @motion-primitives/text-roll ``` -------------------------------- ### Text Shimmer Component Installation Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-shimmer/page.mdx Provides the code to be copied and pasted for manual installation of the Text Shimmer component. Ensure to update import paths according to your project structure. ```typescript import { TextShimmer } from '@/components/core/text-shimmer'; export default function Page() { return ( Shimmer Text ); } ``` -------------------------------- ### Manual Installation of Text Shimmer Wave Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-shimmer-wave/page.mdx Manually install the text shimmer wave component by copying the provided code into your project. Ensure to update import paths as needed. ```tsx import { Steps, Step } from 'react-joyride'; import { CodeBlock } from '@/components/code-block'; // ... Copy and paste the following code into your project. Update the import paths to match your project setup. ``` -------------------------------- ### Card with Transition Panel Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/transition-panel/page.mdx Illustrates the usage of the Transition Panel within a card component for animated content transitions. ```tsx import { TransitionPanelCard } from './transition-panel-card'; import ComponentCodePreview from '@/components/website/component-code-preview'; // ... other imports and component logic } filePath='app/docs/transition-panel/transition-panel-card.tsx' /> ``` -------------------------------- ### Text Morph Component Installation Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-morph/page.mdx Copy and paste this code to manually install the Text Morph component into your project. Ensure to update import paths as needed. ```typescript import { motion } from 'framer-motion'; interface TextMorphProps { children: string; as?: keyof JSX.IntrinsicElements; className?: string; style?: React.CSSProperties; } export function TextMorph({ children, as, className, style }: TextMorphProps) { const Component = as || 'p'; return ( {children.split('').map((char, i) => ( {char === ' ' ? '\u00A0' : char} ))} ); } ``` -------------------------------- ### Basic Text Loop Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-loop/page.mdx Demonstrates the fundamental usage of the Text Loop component for simple looping text animations. ```typescript import { TextLoopBasic } from './text-loop-basic'; // ... ``` -------------------------------- ### Manual Installation of Infinite Slider Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/infinite-slider/page.mdx Code snippet for manual installation of the Infinite Slider component. Copy this code into your project and adjust import paths as needed. ```tsx import React from 'react'; interface InfiniteSliderProps { children: React.ReactNode; gap?: number; speed?: number; speedOnHover?: number; direction?: 'horizontal' | 'vertical'; reverse?: boolean; className?: string; } const InfiniteSlider: React.FC = ({ children, gap = 16, speed = 100, speedOnHover, direction = 'horizontal', reverse = false, className }) => { // Component implementation details... return (
{/* Slider content will be rendered here */} {children}
); }; export default InfiniteSlider; ``` -------------------------------- ### Morphing Dialog Basic Example 2 Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/morphing-dialog/page.mdx Renders a second variation of the basic morphing dialog. Verify import paths. ```tsx import { MorphingDialogBasicTwo } from './morphing-dialog-basic-2'; import ComponentCodePreview from '@/components/website/component-code-preview'; // ... } filePath='app/docs/morphing-dialog/morphing-dialog-basic-2.tsx' /> ``` -------------------------------- ### Run Motion Primitives CLI with npx Source: https://github.com/ibelick/motion-primitives/blob/main/cli/README.md Execute the CLI commands directly using npx without global installation. ```bash npx motion-primitives ``` -------------------------------- ### Morphing Dialog Basic Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/morphing-dialog/page.mdx Renders a basic morphing dialog. Ensure the component is correctly imported. ```tsx import { MorphingDialogBasicOne } from './morphing-dialog-basic-1'; import ComponentCodePreview from '@/components/website/component-code-preview'; // ... } filePath='app/docs/morphing-dialog/morphing-dialog-basic-1.tsx' /> ``` -------------------------------- ### Animated Number Counter Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/animated-number/page.mdx Shows how to use the Animated Number component as a counter. This example likely involves passing dynamic values to the component to trigger the counting animation. ```tsx import { AnimatedNumberCounter } from './animated-number-counter'; function App() { return ; } ``` -------------------------------- ### Morphing Popover Basic Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/morphing-popover/page.mdx Demonstrates the basic usage of the Morphing Popover component. This snippet shows how to implement a simple popover with default animations. ```jsx import { MorphingPopoverBasic } from './morphing-popover-basic'; function App() { return ; } ``` -------------------------------- ### Scroll Progress Gradient Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/scroll-progress/page.mdx An example showcasing a scroll progress indicator with a gradient effect. This snippet likely utilizes custom styling for the progress bar. ```tsx import { ScrollProgress } from '@/components/core/scroll-progress'; export function ScrollProgressBasic3() { return ( ); } ``` -------------------------------- ### Manual Installation of Text Roll Component Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-roll/page.mdx Details the manual installation process by providing the core component code. Ensure to update import paths according to your project structure. ```tsx import React from 'react'; import { motion } from 'framer-motion'; interface TextRollProps { children: React.ReactNode; className?: string; duration?: number; getEnterDelay?: (i: number) => number; getExitDelay?: (i: number) => number; transition?: object; variants?: object; onAnimationComplete?: () => void; } const TextRoll: React.FC = ({ children, className = '', duration = 0.5, getEnterDelay = (i) => i * 0.1, getExitDelay = (i) => i * 0.1 + 0.2, transition = { ease: 'easeIn' }, variants, onAnimationComplete, }) => { const characters = React.Children.toArray(children); return (
{characters.map((char, i) => ( {char} ))}
); }; export default TextRoll; ``` -------------------------------- ### Basic Disclosure Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/disclosure/page.mdx Demonstrates the fundamental usage of the Disclosure component for toggling content visibility. ```tsx import { DisclosureBasic } from './disclosure-basic'; import ComponentCodePreview from '@/components/website/component-code-preview'; // ... } filePath='app/docs/disclosure/disclosure-basic.tsx' classNameComponentContainer='min-h-0 py-24 lg:px-32 px-8' /> ``` -------------------------------- ### Morphing Popover with Textarea Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/morphing-popover/page.mdx Illustrates using the Morphing Popover component in conjunction with a textarea element. This example is useful for popovers that interact with input fields. ```jsx import { MorphingPopoverTextarea } from './morphing-popover-textarea'; function App() { return ; } ``` -------------------------------- ### Infinite Slider Basic Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/infinite-slider/page.mdx Demonstrates the basic usage of the Infinite Slider component. This snippet shows how to render a simple slider with its default settings. ```tsx import { InfiniteSliderBasic } from './infinite-slider-basic'; function App() { return ; } ``` -------------------------------- ### Morphing Dialog Image Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/morphing-dialog/page.mdx Displays a morphing dialog with image content. Check that the component and its path are correctly referenced. ```tsx import { MorphingDialogBasicImage } from './morphing-dialog-image'; import ComponentCodePreview from '@/components/website/component-code-preview'; // ... } filePath='app/docs/morphing-dialog/morphing-dialog-image.tsx' /> ``` -------------------------------- ### Controlled Dialog Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/dialog/page.mdx Shows how to control the open state of the dialog using the `open` and `onOpenChange` props. This allows for programmatic control over the dialog's visibility. ```typescript import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose, } from '@/components/ui/dialog'; import { useState, useCallback, useMemo, useRef, useEffect, } from 'react'; export function DialogControlled() { const [open, setOpen] = useState(false); const handleOpenChange = useCallback((isOpen: boolean) => { setOpen(isOpen); }, []); return ( Share link Anyone who has this link will be able to view this.
); } ``` -------------------------------- ### Scroll Progress Basic Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/scroll-progress/page.mdx A basic implementation of the scroll progress indicator. This snippet shows the fundamental usage of the ScrollProgress component. ```tsx import { ScrollProgress } from '@/components/core/scroll-progress'; export function ScrollProgressBasic1() { return ( ); } ``` -------------------------------- ### Cursor with Image and Spring Animation Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/cursor/page.mdx Demonstrates a cursor component with an image and spring-based animations. This example utilizes the Cursor1 component. ```tsx import { Cursor1 } from './cursor-1'; // ... } filePath='app/docs/cursor/cursor-1.tsx' /> ``` -------------------------------- ### Manual Installation of Animated Number Component Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/animated-number/page.mdx Provides the code to be manually copied and pasted into your project for the Animated Number component. Remember to update import paths according to your project structure. ```tsx import { motion } from 'framer-motion'; import { useRef } from 'react'; import { useInView } from 'react-intersection-observer'; interface AnimatedNumberProps { value: number; className?: string; springOptions?: object; as?: React.ElementType; } export function AnimatedNumber({ value, className, springOptions, as: Component = 'span', }: AnimatedNumberProps) { const ref = useRef(null); const [inViewRef, inView] = useInView({ triggerOnce: true, }); return (
{value}
); } ``` -------------------------------- ### Animated Number Basic Usage Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/animated-number/page.mdx Demonstrates the basic implementation of the Animated Number component. No specific setup is required beyond importing the component. ```tsx import { AnimatedNumberBasic } from './animated-number-basic'; function App() { return ; } ``` -------------------------------- ### Text Scramble Basic Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/text-scramble/page.mdx Demonstrates the basic usage of the TextScramble component. This snippet shows how to apply the default text scrambling effect. ```typescript import { TextScrambleBasic } from './text-scramble-basic'; // ... ``` -------------------------------- ### In View Component Code (Manual Installation) Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/in-view/page.mdx Presents the core code for the In View component, intended for manual integration into a project. Ensure import paths are updated to match your project structure. ```typescript import { InView, useInView } from 'react-intersection-observer'; import { motion, AnimatePresence } from 'framer-motion'; import { cn } from '@/lib/utils'; const variants = { hidden: { opacity: 0, }, visible: { opacity: 1, }, }; export function InView({ children, className, variants: componentVariants, transition, viewOptions, as: Component = 'div', once, ...props }) { const { inView, ref } = useInView({ ...viewOptions, triggerOnce: once, }); return ( {typeof children === 'function' ? children({ inView }) : children} ); } ``` -------------------------------- ### Add Text Effect Component via CLI Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/installation/page.mdx Use the provided command to add the Text Effect component to your project. This command automates the setup for this specific component. ```bash npx motion-primitives@latest text-effect ``` -------------------------------- ### Add a Specific Motion Component Source: https://github.com/ibelick/motion-primitives/blob/main/cli/README.md Add a desired component to your React project. The CLI handles directory creation, file download, and dependency installation. ```bash npx motion-primitives add ``` -------------------------------- ### Toolbar Dynamic Component Preview Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/toolbar-dynamic/page.mdx Renders a preview of the ToolbarDynamic component. The component itself is designed to adjust its width dynamically based on the tools it contains, starting small and expanding as needed. ```javascript import ToolbarDynamic from '@/components/core/toolbar-dynamic'; import ComponentCodePreview from '@/components/website/component-code-preview'; } filePath='components/core/toolbar-dynamic.tsx' /> ``` -------------------------------- ### Install Morphing Dialog Manually Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/morphing-dialog/page.mdx Provides the core code for the Morphing Dialog component to be manually integrated into a project. Ensure import paths are updated to match your project structure. ```tsx import { useState, useRef, useEffect, useCallback } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { cn } from '@/lib/utils'; interface MorphingDialogProps { children: React.ReactNode; isOpen: boolean; onClose: () => void; className?: string; overlayClassName?: string; contentClassName?: string; } export function MorphingDialog({ children, isOpen, onClose, className, overlayClassName, contentClassName, }: MorphingDialogProps) { const overlayRef = useRef(null); const handleKeyDown = useCallback( (event: KeyboardEvent) => { if (event.key === 'Escape' && isOpen) { onClose(); } }, [isOpen, onClose] ); useEffect(() => { document.addEventListener('keydown', handleKeyDown); return () => { document.removeEventListener('keydown', handleKeyDown); }; }, [handleKeyDown]); const handleClickOutside = useCallback( (event: MouseEvent) => { if ( overlayRef.current && !overlayRef.current.contains(event.target as Node) && isOpen ) { onClose(); } }, [isOpen, onClose] ); useEffect(() => { document.addEventListener('mousedown', handleClickOutside); return () => { document.removeEventListener('mousedown', handleClickOutside); }; }, [handleClickOutside]); const overlayVariants = { hidden: { opacity: 0, transition: { when: 'afterChildren', }, }, visible: { opacity: 1, transition: { when: 'beforeChildren', }, }, }; const contentVariants = { hidden: { opacity: 0, scale: 0.95, }, visible: { opacity: 1, scale: 1, transition: { duration: 0.3, }, }, }; return ( {isOpen && ( e.stopPropagation()} // Prevent clicks inside from closing the dialog > {children} )} ); } ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/ibelick/motion-primitives/blob/main/CONTRIBUTING.md Change your current directory to the cloned motion-primitives project folder. ```bash cd motion-primitives ``` -------------------------------- ### List Available Motion Components Source: https://github.com/ibelick/motion-primitives/blob/main/cli/README.md Use this command to view all available animated components, their descriptions, and dependencies. ```bash npx motion-primitives list ``` -------------------------------- ### Clock Component Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/sliding-number/page.mdx Displays a clock component. This is a visual example of the Sliding Number component in action. ```tsx import { SlidingNumber, SlidingNumberProps, } from './sliding-number'; export const Clock = () => { return (
); }; ``` -------------------------------- ### Basic Spotlight Usage Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/spotlight/page.mdx Demonstrates the basic implementation of the spotlight component. This is the default configuration. ```tsx import { SpotlightBasic } from './spotlight-basic'; function App() { return ; } ``` -------------------------------- ### Basic Sliding Number Example Source: https://github.com/ibelick/motion-primitives/blob/main/app/docs/sliding-number/page.mdx A fundamental example of the SlidingNumber component. This snippet shows the basic usage without additional controls. ```tsx import { SlidingNumber, SlidingNumberProps, } from './sliding-number'; export const SlidingNumberBasic = () => { return (
); }; ```