Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

fix: add playsInline for video text

Dillion Verma4c11acaf7799
diff --git a/public/r/smooth-cursor-demo.json b/public/r/smooth-cursor-demo.json
index 67bc0308..63287b03 100644
--- a/public/r/smooth-cursor-demo.json
+++ b/public/r/smooth-cursor-demo.json
@@ -9,7 +9,7 @@
"files": [
{
"path": "registry/example/smooth-cursor-demo.tsx",
- "content": "import { SmoothCursor } from \"@/registry/magicui/smooth-cursor\";\n\nexport default function SmoothCursorDemo() {\n return (\n <div className=\"relative\">\n <span className=\"hidden md:block\">Move your mouse around</span>\n <span className=\"block md:hidden\">Tap anywhere to see the cursor</span>\n <SmoothCursor />\n </div>\n );\n}\n",
+ "content": "import { SmoothCursor } from \"@/registry/magicui/smooth-cursor\";\n\nexport default function SmoothCursorDemo() {\n return (\n <>\n <span className=\"hidden md:block\">Move your mouse around</span>\n <span className=\"block md:hidden\">Tap anywhere to see the cursor</span>\n <SmoothCursor />\n </>\n );\n}\n",
"type": "registry:example",
"target": "components/smooth-cursor-demo.tsx"
}
diff --git a/public/r/video-text.json b/public/r/video-text.json
index b0445d4f..0e38d82f 100644
--- a/public/r/video-text.json
+++ b/public/r/video-text.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "registry/magicui/video-text.tsx",
- "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport React, { ElementType, ReactNode, useEffect, useState } from \"react\";\n\nexport interface VideoTextProps {\n /**\n * The video source URL\n */\n src: string;\n /**\n * Additional className for the container\n */\n className?: string;\n /**\n * Whether to autoplay the video\n */\n autoPlay?: boolean;\n /**\n * Whether to mute the video\n */\n muted?: boolean;\n /**\n * Whether to loop the video\n */\n loop?: boolean;\n /**\n * Whether to preload the video\n */\n preload?: \"auto\" | \"metadata\" | \"none\";\n /**\n * The content to display (will have the video \"inside\" it)\n */\n children: ReactNode;\n /**\n * Font size for the text mask (in viewport width units)\n * @default 10\n */\n fontSize?: string | number;\n /**\n * Font weight for the text mask\n * @default \"bold\"\n */\n fontWeight?: string | number;\n /**\n * Text anchor for the text mask\n * @default \"middle\"\n */\n textAnchor?: string;\n /**\n * Dominant baseline for the text mask\n * @default \"middle\"\n */\n dominantBaseline?: string;\n /**\n * Font family for the text mask\n * @default \"sans-serif\"\n */\n fontFamily?: string;\n /**\n * The element type to render for the text\n * @default \"div\"\n */\n as?: ElementType;\n}\n\nexport function VideoText({\n src,\n children,\n className = \"\",\n autoPlay = true,\n muted = true,\n loop = true,\n preload = \"auto\",\n fontSize = 20,\n fontWeight = \"bold\",\n textAnchor = \"middle\",\n dominantBaseline = \"middle\",\n fontFamily = \"sans-serif\",\n as: Component = \"div\",\n}: VideoTextProps) {\n const [svgMask, setSvgMask] = useState(\"\");\n const content = React.Children.toArray(children).join(\"\");\n\n useEffect(() => {\n const updateSvgMask = () => {\n const responsiveFontSize =\n typeof fontSize === \"number\" ? `${fontSize}vw` : fontSize;\n const newSvgMask = `<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%'><text x='50%' y='50%' font-size='${responsiveFontSize}' font-weight='${fontWeight}' text-anchor='${textAnchor}' dominant-baseline='${dominantBaseline}' font-family='${fontFamily}'>${content}</text></svg>`;\n setSvgMask(newSvgMask);\n };\n\n updateSvgMask();\n window.addEventListener(\"resize\", updateSvgMask);\n return () => window.removeEventListener(\"resize\", updateSvgMask);\n }, [content, fontSize, fontWeight, textAnchor, dominantBaseline, fontFamily]);\n\n const dataUrlMask = `url(\"data:image/svg+xml,${encodeURIComponent(svgMask)}\")`;\n\n return (\n <Component className={cn(`relative size-full`, className)}>\n {/* Create a container that masks the video to only show within text */}\n <div\n className=\"absolute inset-0 flex items-center justify-center\"\n style={{\n maskImage: dataUrlMask,\n WebkitMaskImage: dataUrlMask,\n maskSize: \"contain\",\n WebkitMaskSize: \"contain\",\n maskRepeat: \"no-repeat\",\n WebkitMaskRepeat: \"no-repeat\",\n maskPosition: \"center\",\n WebkitMaskPosition: \"center\",\n }}\n >\n <video\n className=\"w-full h-full object-cover\"\n autoPlay={autoPlay}\n muted={muted}\n loop={loop}\n preload={preload}\n >\n <source src={src} />\n Your browser does not support the video tag.\n </video>\n </div>\n\n {/* Add a backup text element for SEO/accessibility */}\n <span className=\"sr-only\">{content}</span>\n </Component>\n );\n}\n",
+ "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport React, { ElementType, ReactNode, useEffect, useState } from \"react\";\n\nexport interface VideoTextProps {\n /**\n * The video source URL\n */\n src: string;\n /**\n * Additional className for the container\n */\n className?: string;\n /**\n * Whether to autoplay the video\n */\n autoPlay?: boolean;\n /**\n * Whether to mute the video\n */\n muted?: boolean;\n /**\n * Whether to loop the video\n */\n loop?: boolean;\n /**\n * Whether to preload the video\n */\n preload?: \"auto\" | \"metadata\" | \"none\";\n /**\n * The content to display (will have the video \"inside\" it)\n */\n children: ReactNode;\n /**\n * Font size for the text mask (in viewport width units)\n * @default 10\n */\n fontSize?: string | number;\n /**\n * Font weight for the text mask\n * @default \"bold\"\n */\n fontWeight?: string | number;\n /**\n * Text anchor for the text mask\n * @default \"middle\"\n */\n textAnchor?: string;\n /**\n * Dominant baseline for the text mask\n * @default \"middle\"\n */\n dominantBaseline?: string;\n /**\n * Font family for the text mask\n * @default \"sans-serif\"\n */\n fontFamily?: string;\n /**\n * The element type to render for the text\n * @default \"div\"\n */\n as?: ElementType;\n}\n\nexport function VideoText({\n src,\n children,\n className = \"\",\n autoPlay = true,\n muted = true,\n loop = true,\n preload = \"auto\",\n fontSize = 20,\n fontWeight = \"bold\",\n textAnchor = \"middle\",\n dominantBaseline = \"middle\",\n fontFamily = \"sans-serif\",\n as: Component = \"div\",\n}: VideoTextProps) {\n const [svgMask, setSvgMask] = useState(\"\");\n const content = React.Children.toArray(children).join(\"\");\n\n useEffect(() => {\n const updateSvgMask = () => {\n const responsiveFontSize =\n typeof fontSize === \"number\" ? `${fontSize}vw` : fontSize;\n const newSvgMask = `<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%'><text x='50%' y='50%' font-size='${responsiveFontSize}' font-weight='${fontWeight}' text-anchor='${textAnchor}' dominant-baseline='${dominantBaseline}' font-family='${fontFamily}'>${content}</text></svg>`;\n setSvgMask(newSvgMask);\n };\n\n updateSvgMask();\n window.addEventListener(\"resize\", updateSvgMask);\n return () => window.removeEventListener(\"resize\", updateSvgMask);\n }, [content, fontSize, fontWeight, textAnchor, dominantBaseline, fontFamily]);\n\n const dataUrlMask = `url(\"data:image/svg+xml,${encodeURIComponent(svgMask)}\")`;\n\n return (\n <Component className={cn(`relative size-full`, className)}>\n {/* Create a container that masks the video to only show within text */}\n <div\n className=\"absolute inset-0 flex items-center justify-center\"\n style={{\n maskImage: dataUrlMask,\n WebkitMaskImage: dataUrlMask,\n maskSize: \"contain\",\n WebkitMaskSize: \"contain\",\n maskRepeat: \"no-repeat\",\n WebkitMaskRepeat: \"no-repeat\",\n maskPosition: \"center\",\n WebkitMaskPosition: \"center\",\n }}\n >\n <video\n className=\"w-full h-full object-cover\"\n autoPlay={autoPlay}\n muted={muted}\n loop={loop}\n preload={preload}\n playsInline\n >\n <source src={src} />\n Your browser does not support the video tag.\n </video>\n </div>\n\n {/* Add a backup text element for SEO/accessibility */}\n <span className=\"sr-only\">{content}</span>\n </Component>\n );\n}\n",
"type": "registry:ui",
"target": "components/magicui/video-text.tsx"
}
diff --git a/registry/magicui/video-text.tsx b/registry/magicui/video-text.tsx
index a54e38e1..d3094600 100644
--- a/registry/magicui/video-text.tsx
+++ b/registry/magicui/video-text.tsx
@@ -119,6 +119,7 @@ export function VideoText({
muted={muted}
loop={loop}
preload={preload}
+ playsInline
>
<source src={src} />
Your browser does not support the video tag.