Audio
more-shadcn-noair/audioFreeComponent
A modern audio player with progress scrubbing and volume controls.
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.jsonSource
1<script lang="ts">2 import { cn } from '$UTILS$';3 import { setAudioPlayerContext } from './ctx';4 import type { Snippet } from 'svelte';56 let {7 src,8 class: className,9 children10 }: {11 src: string;12 class?: string;13 children: Snippet;14 } = $props();1516 let audio: HTMLAudioElement;1718 let isPaused = $state(true);19 let duration = $state(0);20 let currentTime = $state(0);21 let volume = $state(1);22 let isMuted = $state(false);2324 function togglePlay() {25 if (!audio) return;26 if (audio.paused) {27 audio.play();28 } else {29 audio.pause();30 }31 }3233 function seek(time: number) {34 if (!audio) return;35 audio.currentTime = time;36 currentTime = time;37 }3839 function setVolume(v: number) {40 if (!audio) return;41 audio.volume = v;42 volume = v;43 }4445 function toggleMute() {46 isMuted = !isMuted;47 }4849 setAudioPlayerContext({50 get isPlaying() {51 return { value: !isPaused };52 },53 get duration() {54 return { value: duration };55 },56 get currentTime() {57 return { value: currentTime };58 },59 get volume() {60 return { value: volume };61 },62 get isMuted() {63 return { value: isMuted };64 },65 togglePlay,66 seek,67 setVolume,68 toggleMute69 });70</script>7172<div73 class={cn(74 'relative overflow-hidden rounded-xl border bg-card text-card-foreground shadow-sm',75 className76 )}77>78 <audio79 bind:this={audio}80 {src}81 bind:paused={isPaused}82 bind:currentTime83 bind:duration84 bind:volume85 bind:muted={isMuted}86 ></audio>87 {@render children()}88</div>
What it pulls in
Other registry items
More from more-shadcn-noair
All 43 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Audio Waveaudio-wave | 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 |
