Media Between Text
fancy/media-between-textFreeComponent
A ui component.
Install it
npx shadcn@latest add https://www.fancycomponents.dev/r/media-between-text.jsonSource
1"use client"23import { ElementType, forwardRef, useImperativeHandle, useRef, useState } from "react"4import { motion, useInView, UseInViewOptions, Variants } from "motion/react"56import { cn } from "@/lib/utils"78interface MediaBetweenTextProps {9 /**10 * The text to display before the media11 */12 firstText: string1314 /**15 * The text to display after the media16 */17 secondText: string1819 /**20 * URL of the media (image or video) to display21 */22 mediaUrl: string2324 /**25 * Type of media to display26 */27 mediaType: "image" | "video"2829 /**30 * Optional class name for the media container31 */32 mediaContainerClassName?: string3334 /**35 * Fallback URL for video poster or image loading36 */37 fallbackUrl?: string3839 /**40 * HTML Tag to render the text elements as41 * @default p42 */43 as?: ElementType4445 /**46 * Whether video should autoplay47 * @default true48 */49 autoPlay?: boolean5051 /**52 * Whether video should loop53 * @default true54 */55 loop?: boolean5657 /**58 * Whether video should be muted59 * @default true60 */61 muted?: boolean6263 /**64 * Whether video should play inline65 * @default true66 */67 playsInline?: boolean6869 /**70 * Alt text for image71 */72 alt?: string7374 /**75 * Type of animation trigger76 * @default "hover"77 */78 triggerType?: "hover" | "ref" | "inView"7980 /**81 * Reference to container element for inView trigger82 */83 containerRef?: React.RefObject<HTMLDivElement | null>8485 /**86 * Options for useInView hook87 */88 useInViewOptionsProp?: UseInViewOptions8990 /**91 * Custom animation variants92 */93 animationVariants?: {94 initial: Variants["initial"]95 animate: Variants["animate"]96 }9798 /**99 * Optional class name for the root element100 */101 className?: string102103 /**104 * Optional class name for the left text element105 */106 leftTextClassName?: string107108 /**109 * Optional class name for the right text element110 */111 rightTextClassName?: string112}113114export type MediaBetweenTextRef = {115 animate: () => void116 reset: () => void117}118119export const MediaBetweenText = forwardRef<120 MediaBetweenTextRef,121 MediaBetweenTextProps122>(123 (124 {125 firstText,126 secondText,127 mediaUrl,128 mediaType,129 mediaContainerClassName,130 fallbackUrl,131 as = "p",132 autoPlay = true,133 loop = true,134 muted = true,135 playsInline = true,136 alt,137 triggerType = "hover",138 containerRef,139 useInViewOptionsProp = {140 once: true,141 amount: 0.5,142// … truncated
What it pulls in
npm packages
Files it writes
More from fancy
All 158 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Gradient With Svganimated-gradient-with-svg | fancy | Components | Free | no deps | |
| Basic Number Tickerbasic-number-ticker | fancy | Components | Free | 1 dep | |
| Box Carouselbox-carousel | fancy | Components | Free | 1 dep | |
| Breathing Textbreathing-text | fancy | Components | Free | 1 dep | |
| Circling Elementscircling-elements | fancy | Components | Free | 1 dep | |
| Css Boxcss-box | fancy | Components | Free | 1 dep | |
| Cursor Attractor And Gravitycursor-attractor-and-gravity | fancy | Components | Free | 5 deps | |
| Drag Elementsdrag-elements | fancy | Components | Free | 1 dep |
