v0
Animated Vercel v0 composer — types a prompt into the dark textarea and the mic button morphs into a send button. Dark/light themes.
Source
components/kuchi/v0.tsx
1"use client";23import { loadFont } from "@remotion/google-fonts/Inter";4import {5 AbsoluteFill,6 interpolate,7 spring,8 useCurrentFrame,9 useVideoConfig,10} from "remotion";11import { Caret } from "@/components/kuchi/type-caret";12import { useTypewriter } from "@/lib/kuchi-kit";1314const { fontFamily: SANS_FAMILY } = loadFont();1516export interface V0Props {17 greeting?: string;18 placeholder?: string;19 prompt?: string;20 modelName?: string;21 projectName?: string;22 speed?: number;23}2425interface Theme {26 page: string;27 boxBg: string;28 boxBorder: string;29 fg: string;30 fgMuted: string;31 iconColor: string;32 btnBg: string;33 btnFg: string;34}3536export const THEMES: Record<"light" | "dark", Theme> = {37 light: {38 page: "#FFFFFF",39 boxBg: "#FFFFFF",40 boxBorder: "#E3E3E3",41 fg: "#0D0D0D",42 fgMuted: "#8A8A8A",43 iconColor: "#5D5D5D",44 btnBg: "#0D0D0D",45 btnFg: "#FFFFFF",46 },47 dark: {48 page: "#000000",49 boxBg: "#0A0A0A",50 boxBorder: "#2A2A2A",51 fg: "#EDEDED",52 fgMuted: "#8A8A8A",53 iconColor: "#A0A0A0",54 btnBg: "#FFFFFF",55 btnFg: "#0A0A0A",56 },57};5859export const TYPING_START_FRAME = 42;6061export const TYPING_CPS = 22;6263export function morphProgressAt(64 frame: number,65 opts: { startFrame?: number; fps: number; speed: number },66): number {67 const startFrame = opts.startFrame ?? TYPING_START_FRAME;68 const value = spring({69 fps: opts.fps,70 frame: frame * opts.speed - startFrame,71 config: { damping: 14, stiffness: 200, mass: 0.6 },72 });73 return Math.max(0, Math.min(value, 1));74}7576function introBounceIn(77 frame: number,78 fps: number,79): { translateY: number; scale: number } {80 const s = spring({81 fps,82 frame,83 config: { damping: 14, stiffness: 110, mass: 0.7 },84 });85 const translateY = interpolate(s, [0, 1], [28, 0]);86 const scale = interpolate(s, [0, 1], [0.97, 1]);87 return { translateY, scale };88}8990function fadeUpAt(91 frame: number,92 range: [number, number],93): { opacity: number; translateY: number } {94 const opts = {95 extrapolateLeft: "clamp" as const,96 extrapolateRight: "clamp" as const,97 };98 return {99 opacity: interpolate(frame, range, [0, 1], opts),100 translateY: interpolate(frame, range, [12, 0], opts),101 };102}103104function PlusIcon({ size, color }: { size: number; color: string }) {105 return (106 <svg width={size} height={size} viewBox="0 0 24 24" fill="none">107 <title>Add</title>108 <path109 d="M12 5v14M5 12h14"110 stroke={color}111 strokeWidth={2}112 strokeLinecap="round"113 />114 </svg>115 );116}117118function V0LogoIcon({ size, color }: { size: number; color: string }) {119 return (120 <svg width={size} height={size} viewBox="0 0 24 24" fill="none">121 <title>v0</title>122 <rect123 x={2.5}124 y={2.5}125 width={19}126 height={19}127 rx={5}128 stroke={color}129 strokeWidth={1.8}130 />131 <rect132 x={7.5}133 y={7.5}134 width={9}135 height={9}136 rx={2.5}137 stroke={color}138 strokeWidth={1.8}139 />140 </svg>141 );142}143144function ChevronDownIcon({ size, color }: { size: number; color: string }) {145 return (146 <svg width={size} height={size} viewBox="0 0 24 24" fill="none">147 <title>Expand</title>148 <path149 d="M6 9l6 6 6-6"150 stroke={color}151 strokeWidth={2}152 strokeLinecap="round"153 strokeLinejoin="round"154 />155 </svg>156 );157}158159function MicIcon({ size, color }: { size: number; color: string }) {160 return (161 <svg width={size} height={size} viewBox="0 0 24 24" fill="none">162 <title>Voice input</title>163 <rect164 x={9}165 y={3}166 width={6}167 height={11}168 rx={3}169 stroke={color}170 strokeWidth={1.8}171 />172 <path173 d="M5.5 11a6.5 6.5 0 0013 0M12 17.5V21M9 21h6"174 stroke={color}175 strokeWidth={1.8}176 strokeLinecap="round"177 strokeLinejoin="round"178 />179 </svg>180 );181}182183function ArrowUpIcon({ size, color }: { size: number; color: string }) {184 return (185 <svg width={size} height={size} viewBox="0 0 24 24" fill="none">186 <title>Send</title>187 <path188 d="M12 19V6M12 6l-6 6M12 6l6 6"189 stroke={color}190 strokeWidth={2.2}191 strokeLinecap="round"192 strokeLinejoin="round"193 />194 </svg>195 );196}197198export function V0({199 greeting = "What do you want to create?",200 placeholder = "Ask v0 to build…",201 prompt = "a landing page for my SaaS with pricing and testimonials",202 modelName = "v0 Max",203 projectName = "Project",204 speed = 1,205}: V0Props) {206 const frame = useCurrentFrame();207 const { width, height, fps } = useVideoConfig();208 const t = THEMES.dark;209210 const refW = 1280;211 const refH = 720;212 const stageScale = Math.min(width / refW, height / refH);213214 const tw = useTypewriter(prompt, {215 cps: TYPING_CPS,216 speed,217 startFrame: TYPING_START_FRAME,218 });219 const visibleText = tw.text;220 const showText = tw.count > 0;221 const morph = morphProgressAt(frame, { fps, speed });222223 const intro = introBounceIn(frame * speed, fps);224 const headingFade = fadeUpAt(frame * speed, [4, 20]);225 const boxFade = fadeUpAt(frame * speed, [10, 26]);226227 const boxWidth = 880;228 const boxLeft = (refW - boxWidth) / 2;229 const boxTop = 270;230 const boxHeight = 150;231 const btnSize = 40;232233 return (234 <AbsoluteFill style={{ background: "transparent" }}>235 <div236 style={{237 position: "absolute",238 left: "50%",239 top: "50%",240 width: refW,241 height: refH,242 translate: "-50% -50%",243 scale: `${stageScale}`,244 }}245 >246 <div247 style={{248 position: "absolute",249 left: 0,250 top: 150,251 width: refW,252 textAlign: "center",253 fontFamily: SANS_FAMILY,254 fontSize: 44,255 fontWeight: 700,256 color: t.fg,257 opacity: headingFade.opacity,258 translate: `0 ${headingFade.translateY + intro.translateY * 0.4}px`,259 }}260 >261 {greeting}262 </div>263264 <div265 style={{266 position: "absolute",267 left: boxLeft,268 top: boxTop,269 width: boxWidth,270 height: boxHeight,271 background: t.boxBg,272 border: `1px solid ${t.boxBorder}`,273 borderRadius: 16,274 boxShadow: "0 8px 40px -16px rgba(0,0,0,0.8)",275 opacity: boxFade.opacity,276 translate: `0 ${boxFade.translateY + intro.translateY * 0.6}px`,277 scale: `${intro.scale}`,278 transformOrigin: "center top",279 display: "flex",280 flexDirection: "column",281 boxSizing: "border-box",282 }}283 >284 <div285 style={{286 flex: 1,287 padding: "18px 20px",288 fontFamily: SANS_FAMILY,289 fontSize: 18,290 color: t.fg,291 display: "flex",292 alignItems: "flex-start",293 overflow: "hidden",294 }}295 >296 {showText ? (297 <span298 style={{299 color: t.fg,300 whiteSpace: "pre-wrap",301 }}302 >303 {visibleText}304 <Caret305 color={t.fg}306 blink={!tw.typing}307 speed={speed}308 height={20}309 marginLeft={2}310 />311 </span>312 ) : (313 <span314 style={{315 color: t.fgMuted,316 display: "inline-flex",317 alignItems: "center",318 }}319 >320 <Caret321 color={t.fg}322 blink={!tw.typing}323 speed={speed}324 height={20}325 />326 <span style={{ marginLeft: 6 }}>{placeholder}</span>327 </span>328 )}329 </div>330331 <div332 style={{333 padding: "12px 16px",334 display: "flex",335 justifyContent: "space-between",336 alignItems: "center",337 }}338 >339 <div style={{ display: "flex", alignItems: "center", gap: 10 }}>340 <PlusIcon size={20} color={t.iconColor} />341 <div342 style={{343 display: "inline-flex",344 alignItems: "center",345 gap: 7,346 }}347 >348 <V0LogoIcon size={18} color={t.fg} />349 <span350 style={{351 fontFamily: SANS_FAMILY,352 fontSize: 15,353 fontWeight: 500,354 color: t.fg,355 }}356 >357 {modelName}358 </span>359 <ChevronDownIcon size={14} color={t.fgMuted} />360 </div>361 </div>362363 <div style={{ display: "flex", alignItems: "center", gap: 12 }}>364 <div365 style={{366 display: "inline-flex",367 alignItems: "center",368 gap: 4,369 }}370 >371 <span372 style={{373 fontFamily: SANS_FAMILY,374 fontSize: 15,375 color: t.fgMuted,376 }}377 >378 {projectName}379 </span>380 <ChevronDownIcon size={14} color={t.fgMuted} />381 </div>382383 <div384 style={{385 position: "relative",386 width: btnSize,387 height: btnSize,388 borderRadius: 10,389 background: t.btnBg,390 flexShrink: 0,391 }}392 >393 <div394 style={{395 position: "absolute",396 inset: 0,397 display: "flex",398 alignItems: "center",399 justifyContent: "center",400 opacity: 1 - morph,401 scale: `${1 - 0.08 * morph}`,402 }}403 >404 <MicIcon size={20} color={t.btnFg} />405 </div>406 <div407 style={{408 position: "absolute",409 inset: 0,410 display: "flex",411 alignItems: "center",412 justifyContent: "center",413 opacity: morph,414 scale: `${0.85 + 0.15 * morph}`,415 }}416 >417 <ArrowUpIcon size={20} color={t.btnFg} />418 </div>419 </div>420 </div>421 </div>422 </div>423 </div>424 </AbsoluteFill>425 );426}







