An open API service indexing awesome lists of open source software.

https://github.com/gfazioli/mantine-audio

A Mantine-native audio player for React with waveform visualization and live spectrum analyzer, built on Web Audio API. Compound component API + headless useAudio hook.
https://github.com/gfazioli/mantine-audio

audio audio-player component compound-component headless mantine mantine-extension mantine-ui mantine-v9 podcast react react-audio react-component spectrum-analyzer typescript waveform web-audio-api

Last synced: 4 days ago
JSON representation

A Mantine-native audio player for React with waveform visualization and live spectrum analyzer, built on Web Audio API. Compound component API + headless useAudio hook.

Awesome Lists containing this project

README

          

# Mantine Audio Component

Mantine Audio

[![NPM version](https://img.shields.io/npm/v/%40gfazioli%2Fmantine-audio?style=for-the-badge)](https://www.npmjs.com/package/@gfazioli/mantine-audio)
[![NPM Downloads](https://img.shields.io/npm/dm/%40gfazioli%2Fmantine-audio?style=for-the-badge)](https://www.npmjs.com/package/@gfazioli/mantine-audio)
[![NPM Downloads](https://img.shields.io/npm/dy/%40gfazioli%2Fmantine-audio?style=for-the-badge&label=%20&color=f90)](https://www.npmjs.com/package/@gfazioli/mantine-audio)
![NPM License](https://img.shields.io/npm/l/%40gfazioli%2Fmantine-audio?style=for-the-badge)

---

[
 ❤️ If this component has been useful to you or your team, please consider becoming a sponsor 
](https://github.com/sponsors/gfazioli?o=esc)

## Overview

This component is built on top of the [Mantine](https://mantine.dev/) library.

The [Mantine Audio](https://gfazioli.github.io/mantine-audio/) component is a Mantine-native audio player for React with **waveform visualisation** and a **live spectrum analyser**, built on the Web Audio API. It ships as three layers in a single package: a polished default `` with four variants, a fully composable compound API (ten sub-components you can reorder and restyle), and a fully headless `useAudio` hook to build 100% custom UIs.

## Features

- 🎧 **Drop-in player** — `` and you have a styled, accessible audio player
- 🧩 **Compound API** — 10 sub-components (`Audio.PlayButton`, `Audio.Timeline`, `Audio.Waveform`, `Audio.Spectrum`, `Audio.VolumeSlider`, `Audio.SpeedControl`, …) reorderable and re-styleable
- 🪝 **Headless `useAudio` hook** — 16 state values + 12 actions for fully custom UIs
- 🌊 **Waveform visualisation** — peaks decoded via Web Audio + click/drag to seek, 60fps playhead tracking via RAF
- 🎚️ **Live spectrum analyser** — `AnalyserNode` driven, solid or gradient bars, optional mirror
- 🔀 **Multiple `` support** — `sources={[…]}` for codec / format / media-query fallbacks + `fallbackSrc` for runtime errors
- 🎛️ **5 sizes × 4 variants** — `xs/sm/md/lg/xl` × `overlay/minimal/floating/bordered` (all CSS-driven via data attributes)
- 🌅 **`asBackground` preset** — turn the same player into a hero / section ambient track in one line
- 🎚️ **Scrub-with-sound** — optional `scrubSound` lets the user hear snippets while dragging (Audacity / iTunes style)
- ⌨️ **Keyboard shortcuts** — Space, J/K/L, ←/→, ↑/↓, M, > / <
- 🎨 **Full Styles API** — `classNames`, `styles`, `vars`, `unstyled`, theme-aware out of the box
- 📦 **TypeScript** — strict types, every prop documented

> [!note]
>
> → [Demo and Documentation](https://gfazioli.github.io/mantine-audio/) → [More Mantine Components](https://mantine-extensions.vercel.app/)

## Installation

```sh
npm install @gfazioli/mantine-audio
```

or

```sh
yarn add @gfazioli/mantine-audio
```

After installation import package styles at the root of your application:

```tsx
import '@gfazioli/mantine-audio/styles.css';
```

## Usage

```tsx
import { Audio } from '@gfazioli/mantine-audio';

function Demo() {
return ;
}
```

Compound layout with waveform on top and a custom skip button:

```tsx











```

Headless usage with the `useAudio` hook:

```tsx
import { useAudio } from '@gfazioli/mantine-audio';

function MyPlayer() {
const { playing, currentTime, duration, peaks, analyser, toggle, audioRef } = useAudio({
src: '/track.mp3',
});

return (



{playing ? 'Pause' : 'Play'}
{currentTime.toFixed(1)} / {duration.toFixed(1)}

);
}
```

## Sponsor

[
 ❤️ If this component has been useful to you or your team, please consider becoming a sponsor 
](https://github.com/sponsors/gfazioli?o=esc)

Your support helps me:

- Keep the project actively maintained with timely bug fixes and security updates
- Add new features, improve performance, and refine the developer experience
- Expand test coverage and documentation for smoother adoption
- Ensure long‑term sustainability without relying on ad hoc free time
- Prioritize community requests and roadmap items that matter most

Open source thrives when those who benefit can give back—even a small monthly contribution makes a real difference. Sponsorships help cover maintenance time, infrastructure, and the countless invisible tasks that keep a project healthy.

Your help truly matters.

💚 [Become a sponsor](https://github.com/sponsors/gfazioli?o=esc) today and help me keep this project reliable, up‑to‑date, and growing for everyone.

---

[![Star History Chart](https://api.star-history.com/svg?repos=gfazioli/mantine-audio&type=Timeline)](https://www.star-history.com/#gfazioli/mantine-audio&Timeline)