BarsWave
scrollxui/barswaveFreeComponent
Vertical wave bars animate in symmetry, forming a subtle motion-driven background layer.
Live preview
live · rendered by the registry
Rendered by scrollxui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://scrollxui.dev/registry/barswave.jsonSource
1'use client';2import React, { useState } from 'react';3import { motion } from 'motion/react';4import { cn } from '@/lib/utils';56interface BarsWaveProps {7 barCount?: number;8 minHeight?: number;9 maxHeight?: number;10 fillColor?: string;11 borderColor?: string;12 barOpacity?: number;13 animationDuration?: number;14 variant?: 'filled' | 'outlined';15 className?: string;16 children?: React.ReactNode;17}1819export function BarsWave({20 barCount = 15,21 minHeight = 15,22 maxHeight = 85,23 fillColor,24 borderColor,25 barOpacity = 1,26 animationDuration = 3,27 variant = 'outlined',28 className,29 children,30}: BarsWaveProps) {31 const halfCount = Math.ceil(barCount / 2);3233 const [barAnimations] = useState(() => {34 return Array.from({ length: halfCount }, (_, i) => {35 const heights = [36 Math.random() * (maxHeight - minHeight) + minHeight,37 Math.random() * (maxHeight - minHeight) + minHeight,38 Math.random() * (maxHeight - minHeight) + minHeight,39 ];4041 return {42 id: i,43 heights: [...heights, heights[0]],44 delay: Math.random() * 2,45 duration: animationDuration + Math.random() * 2,46 };47 });48 });4950 const allBars = React.useMemo(() => {51 const leftBars = barAnimations.map((bar, i) => ({52 ...bar,53 id: `left-${i}`,54 position: i,55 }));5657 const rightBars = [...barAnimations].reverse().map((bar, i) => ({58 ...bar,59 id: `right-${i}`,60 position: halfCount + i,61 }));6263 return [...leftBars, ...rightBars].slice(0, barCount);64 }, [barAnimations, halfCount, barCount]);6566 return (67 <div className={cn('relative overflow-hidden', className)}>68 <div className='absolute inset-0 flex items-end justify-around gap-1 px-4'>69 {allBars.map((bar) => (70 <motion.div71 key={bar.id}72 className={cn(73 'w-full max-w-20 rounded-t-md',74 variant === 'filled'75 ? 'bg-gray-900/10 dark:bg-white/10'76 : 'bg-transparent border-2 border-gray-900/20 dark:border-white/20',77 )}78 style={{79 ...(fillColor &&80 variant === 'filled' && { backgroundColor: fillColor }),81 ...(borderColor &&82 variant === 'outlined' && { borderColor: borderColor }),83 opacity: barOpacity,84 }}85 initial={{ height: `${bar.heights[0]}%` }}86 animate={{87// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from scrollxui
All 180 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | scrollxui | Components | Free | 4 deps | |
| Alert Dialogalert-dialog | scrollxui | Components | Free | 7 deps | |
| Animated Buttonanimated-button | scrollxui | Components | Free | 4 deps | |
| Animated Tabsanimated-tabs | scrollxui | Components | Free | 1 dep | |
| Animated Testimonialsanimated-testimonials | scrollxui | Components | Free | 2 deps | |
| Animated TextGenerateanimated-textgenerate | scrollxui | Components | Free | 3 deps | |
| Announcementannouncement | scrollxui | Components | Free | 5 deps | |
| Aspect Ratioaspect-ratio | scrollxui | Components | Free | 1 dep |
