falling-text
jolyui-ui/falling-textFreeComponent
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/falling-text.jsonSource
1"use client";2import Matter from "matter-js";3import { useCallback, useEffect, useRef, useState } from "react";45export interface FallingTextProps {6 /** The text content to display and animate */7 text: string;8 /** Words to highlight with special styling */9 highlightWords?: string[];10 /** When to trigger the falling animation */11 trigger?: "auto" | "scroll" | "click" | "hover";12 /** Background color for the physics canvas */13 backgroundColor?: string;14 /** Show physics wireframes for debugging */15 wireframes?: boolean;16 /** Gravity strength (default: 1) */17 gravity?: number;18 /** Mouse interaction stiffness (0-1, default: 0.2) */19 mouseConstraintStiffness?: number;20 /** Font size for the text */21 fontSize?: string;22 /** Custom className for the container */23 className?: string;24 /** Callback when animation starts */25 onAnimationStart?: () => void;26 /** Callback when animation ends (all bodies settled) */27 onAnimationEnd?: () => void;28 /** Physics properties for word bodies */29 physicsOptions?: {30 restitution?: number; // Bounciness (0-1)31 frictionAir?: number; // Air resistance32 friction?: number; // Surface friction33 density?: number; // Mass density34 };35 /** Initial velocity range for words */36 initialVelocity?: {37 x?: number; // Horizontal velocity range38 y?: number; // Vertical velocity range39 angular?: number; // Angular velocity range40 };41 /** Custom highlight styles */42 highlightClassName?: string;43 /** Word spacing in pixels */44 wordSpacing?: number;45 /** Minimum container height */46 minHeight?: string;47 /** Enable/disable mouse interactions */48 enableMouseInteraction?: boolean;49 /** Reset trigger - increment to reset animation */50 resetKey?: number;51}5253const FallingText: React.FC<FallingTextProps> = ({54 text,55 highlightWords = [],56 trigger = "auto",57 backgroundColor = "transparent",58 wireframes = false,59 gravity = 1,60 mouseConstraintStiffness = 0.2,61 fontSize = "1rem",62 className = "",63 onAnimationStart,64 onAnimationEnd,65 physicsOptions = {},66 initialVelocity = {},67 highlightClassName = "text-cyan-500 font-bold",68 wordSpacing = 2,69 minHeight = "300px",70 enableMouseInteraction = true,71 resetKey = 0,72}) => {73 const containerRef = useRef<HTMLDivElement | null>(null);74 const textRef = useRef<HTMLDivElement | null>(null);75 const canvasContainerRef = useRef<HTMLDivElement | null>(null);76 const engineRef = useRef<Matter.Engine | null>(null);77// … truncated
What it pulls in
npm packages
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 |
