Veil UI
Components

Audio Player

A titled native audio player inside a card.

Installation

$ npx veil-ui@latest add audio-player

Usage

import { AudioPlayer } from "@/components/ui/audio-player";

<AudioPlayer src="/track.mp3" title="Product walkthrough" artist="Veil team" />;

Examples

Basic

Product walkthrough

Veil team

Minimal

Audio track

API reference

The package exports audio-player along with its composable parts. It forwards standard attributes to its root element; see the examples above for the component-specific props.

Accessibility

  • Media players use native <video> and <audio> controls with accessible labels.
  • Images require meaningful alt text; clickable thumbnails are buttons named Play <title>.
  • Decorative play overlays, durations and icons are hidden from assistive technology.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add audio-player --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { Music } from "lucide-vue-next";

import { cn } from "@/lib/utils";

const props = defineProps<{
  src: string;
  title?: string;
  artist?: string;
  audioClassName?: string;
  class?: string;
}>();
</script>

<template>
  <figure
    data-slot="audio-player"
    :class="
      cn(
        'flex w-full max-w-md flex-col gap-3 rounded-lg border bg-card p-4',
        props.class,
      )
    "
  >
    <div class="flex items-center gap-3">
      <span class="flex size-9 items-center justify-center rounded-full bg-primary/10 text-primary">
        <Music class="size-4" aria-hidden="true" />
      </span>
      <div class="min-w-0 text-sm">
        <p class="truncate font-medium">{{ title ?? "Audio track" }}</p>
        <p v-if="artist" class="truncate text-xs text-muted-foreground">{{ artist }}</p>
      </div>
    </div>
    <audio
      :src="src"
      controls
      preload="metadata"
      :aria-label="title ?? 'Audio track'"
      :class="cn('w-full', audioClassName)"
    />
  </figure>
</template>

On this page