A customizable React audio player component with TypeScript and Tailwind CSS.
npm install react-wave-audio-player!React Wave Audio Player Preview
sh
npm install react-wave-audio-player
`
$3
Since this package depends on react, react-dom, tailwindcss, wavesurfer.js, and react-icons, ensure they are installed in your project:
`sh
npm install react react-dom tailwindcss wavesurfer.js react-icons
`
$3
If you haven't set up Tailwind CSS, follow the official documentation:
š Tailwind CSS Setup: Using Tailwind with Vite
---
š Usage
$3
`tsx
import React from "react";
import { AudioPlayer } from "react-wave-audio-player";
const App = () => {
return (
);
};
export default App;
`
$3
`tsx
src="/audio/sample.mp3"
waveColor="#a3aed0"
progressColor="#3311db"
cursorColor="blue"
buttonsColor="#ff5722"
barWidth={3}
barRadius={2}
barGap={1}
height={80}
playIcon={ }
pauseIcon={ }
volumeUpIcon={ }
volumeMuteIcon={ }
playbackSpeeds={[0.5, 1, 1.5, 2]}
onPlay={() => console.log("Playing")}
onPause={() => console.log("Paused")}
onVolumeChange={(vol) => console.log("Volume: ", vol)}
/>
`
---
šØ Props & Customization
| Prop | Type | Default | Description |
| ---------------- | -------------------------- | -------------------------- | ---------------------------------- |
| src | string | Required | URL of the audio file |
| waveColor | string | "#a3aed0" | Color of waveform |
| progressColor | string | "#3311db" | Color of progress bar |
| cursorColor | string | "blue" | Color of cursor |
| buttonsColor | string | "#3311db" | Color of control buttons |
| barWidth | number | 2 | Width of waveform bars |
| barRadius | number | 2 | Radius of waveform bars |
| barGap | number | 1 | Gap between waveform bars |
| height | number | 100 | Height of the waveform |
| playIcon | ReactNode | | Custom play icon |
| pauseIcon | ReactNode | | Custom pause icon |
| volumeUpIcon | ReactNode | | Custom volume up icon |
| volumeMuteIcon | ReactNode | | Custom mute icon |
| playbackSpeeds | number[] | [1, 1.5, 2] | Available playback speed options |
| onPlay | () => void | undefined | Callback when audio starts playing |
| onPause | () => void | undefined | Callback when audio pauses |
| onVolumeChange | (volume: number) => void | undefined` | Callback when volume changes |