Audio Wave
more-shadcn-noair/audio-waveFreeComponent
An audio visualization component
Live preview
live · rendered by the registry
Rendered by more-shadcn-noair on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://more-shadcn.noair.fun/r/audio-wave.jsonSource
1<script lang="ts">2 import { cn } from '$UTILS$';34 let {5 playing = true,6 bars = 4,7 class: className,8 barColor = 'bg-primary',9 ...rest10 }: {11 playing?: boolean;12 bars?: number;13 class?: string;14 barColor?: string;15 [key: string]: any;16 } = $props();1718 let heights = $state(Array(bars).fill(0.25));19 let frame: number;2021 function lerp(start: number, end: number, factor: number) {22 return start + (end - start) * factor;23 }2425 $effect(() => {26 if (heights.length !== bars) {27 heights = Array(bars).fill(0.25);28 }2930 const animate = () => {31 const time = performance.now() / 1000;3233 heights = heights.map((h, i) => {34 let target = 0.25;3536 if (playing) {37 const input = (time - i * 0.15) * (Math.PI * 2);38 const sine = (Math.sin(input) + 1) / 2;39 target = 0.25 + sine * 0.75;40 }4142 return lerp(h, target, 0.15);43 });4445 frame = requestAnimationFrame(animate);46 };4748 frame = requestAnimationFrame(animate);4950 return () => cancelAnimationFrame(frame);51 });52</script>5354<div class={cn('flex items-end justify-center gap-0.5 h-8', className)} {...rest}>55 {#each heights as height, i}56 <div class={cn('w-1 rounded-sm', barColor)} style="height: {height * 100}%;"></div>57 {/each}58</div>
More from more-shadcn-noair
All 43 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Audioaudio | more-shadcn-noair | Components | Free | no deps | |
| Autocompleteautocomplete | more-shadcn-noair | Components | Free | no deps | |
| Bannerbanner | more-shadcn-noair | Components | Free | no deps | |
| Big Calendarbig-calendar | more-shadcn-noair | Components | Free | no deps | |
| Bottom Navigationbottom-nav | more-shadcn-noair | Components | Free | no deps | |
| Canvascanvas | more-shadcn-noair | Components | Free | no deps | |
| Chipchip | more-shadcn-noair | Components | Free | no deps | |
| Choiceboxchoicebox | more-shadcn-noair | Components | Free | no deps |
