Fast by Default Illustration
navdeep-singh/fast-by-default-illustrationFreeComponent
An interactive field of animated speed lines with reduced-motion support.
Install it
npx shadcn@latest add https://ui.navdeepsingh.dev/r/fast-by-default-illustration.jsonSource
1'use client'23import { useState } from 'react'4import { motion, useReducedMotion } from 'motion/react'56const SPEED_LINE_COUNT = 1378const speedLines = Array.from({ length: SPEED_LINE_COUNT }, (_, index) => {9 const center = (SPEED_LINE_COUNT - 1) / 210 const distanceFromCenter = Math.abs(index - center) / center1112 return {13 y: 34 + index * 7.7,14 start: 47 + distanceFromCenter * 16 + Math.sin(index * 1.25) * 7,15 end: 254 - distanceFromCenter * 23 + Math.cos(index * 0.85) * 7,16 thickness: 1.15 + (1 - distanceFromCenter) * 0.45,17 opacity: 0.4 + (1 - distanceFromCenter) * 0.55,18 direction: index <= center ? 1 : -1,19 travel: 8 + (1 - distanceFromCenter) * 9,20 }21})2223function createSpeedLinePath({24 start,25 end,26 y,27 thickness,28}: {29 start: number30 end: number31 y: number32 thickness: number33}) {34 const taperLength = 1235 const roundedEnd = 43637 return [38 `M ${start} ${y}`,39 `L ${start + taperLength} ${y - thickness}`,40 `L ${end - roundedEnd} ${y - thickness}`,41 `Q ${end} ${y - thickness} ${end} ${y}`,42 `Q ${end} ${y + thickness} ${end - roundedEnd} ${y + thickness}`,43 `L ${start + taperLength} ${y + thickness}`,44 'Z',45 ].join(' ')46}4748export function FastByDefaultIllustration() {49 const reduceMotion = useReducedMotion() ?? false50 const [isHovered, setIsHovered] = useState(false)5152 return (53 <div54 aria-hidden="true"55 className="relative h-45 w-full overflow-hidden md:h-60"56 onPointerEnter={() => {57 if (!reduceMotion) setIsHovered(true)58 }}59 onPointerLeave={() => {60 if (!reduceMotion) setIsHovered(false)61 }}62 >63 <svg64 className="absolute inset-0 size-full overflow-visible text-foreground"65 viewBox="0 0 300 160"66 fill="none"67 preserveAspectRatio="xMidYMid meet"68 >69 <defs>70 <clipPath id="speed-lines-clip">71 <rect x="34" y="20" width="232" height="120" rx="8" />72 </clipPath>73 </defs>74 <g clipPath="url(#speed-lines-clip)">75 {speedLines.map((line, index) => {76 const path = createSpeedLinePath(line)77 const travel = line.travel * line.direction7879 return (80 <motion.path81 key={index}82 d={path}83 fill="currentColor"84 initial={false}85 animate={86 isHovered && !reduceMotion87 ? {88// … truncated
What it pulls in
npm packages
Files it writes
More from navdeep-singh
All 64 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Groupanimated-group | navdeep-singh | Components | Free | 1 dep | |
| Animated Numbersanimated-numbers | navdeep-singh | Components | Free | 1 dep | |
| Animated Tabsanimated-tabs | navdeep-singh | Components | Free | 2 deps | |
| Approval Panel Illustrationapproval-panel | navdeep-singh | Components | Free | 2 deps · 2 files | |
| Brand Logobrand-logo | navdeep-singh | Components | Free | 1 dep | |
| Contribution Graphcontribution-graph | navdeep-singh | Components | Free | no deps | |
| Designed for Focus Illustrationdesigned-for-focus-illustration | navdeep-singh | Components | Free | 1 dep | |
| Expandable Cardexpandable-card | navdeep-singh | Components | Free | 4 deps |
