Documentation

A highly-optimized procedural sound engine for the web. No .mp3 or .wav files to load.@usespaceui/sounds

Overview

Everything is generated entirely in the browser using the Web Audio API with Apple device output mastering and 3D spatial panning.

1 Install

Add the package to your project. Zero dependencies. React is optional.

2 Bind

Bind interactions either via HTML data attributes, React hooks, or procedural calls.

3 Play

Enjoy 24 beautifully mastered procedural sound triggers without any network requests.

Installation

Install with your package manager of choice.

1. HTML Data Attributes

You can automatically bind sounds to DOM events without writing repetitive event listeners. Call bind() once in your app entry point, and then use data-space-* attributes on any element. If you leave the attribute empty, it will use its sensible default.

Available Attributes

  • Defaults to tap. Listens to the click event.

Global Page Audio (Adding to <body>)

Because bind() relies on event delegation, you can add data attributes directly to your <body> element (or root layout) to enable app-wide native interactions for right-clicking, copying, and pasting:

AttributeDefault SoundDescription
data-space-click
tap
Plays on general clicks across elements without specific sound overrides.
data-space-contextmenu
open
Plays on every right-click context menu event anywhere on the page.
data-space-copy
copy
Plays on any native copy action (via Ctrl+C or Cmd+C).
data-space-paste
paste
Plays on any native paste action into inputs or editable areas (via Ctrl+V or Cmd+V).

2. React Hook

If you use React, the useSpaceSound hook gives you bound functions to trigger sounds and manage engine settings inside your components.

Note for React users: You can absolutely use the HTML data attributes approach in React instead of hooks! It's often cleaner for simple buttons. Just call bind() once in a root layout or a generic Provider:

...and then in your code, you can use the data-space-* attributes directly on your React elements. Since bind() is observing the DOM globally from the Provider, all data attributes will be automatically activated.

3. Programmatic Usage

You can also trigger sounds procedurally and adjust the engine settings globally via direct imports.

4. Output Profile

The output profile adjusts the mastering EQ curve applied to all sounds. This allows you to optimize the audio output for different listening environments.

ProfileDescription
auto
Detects the device and picks the best EQ curve automatically. (Default)
headphones
Flatter response with subtle bass lift for close-ear listening.
speakers
Compensates for typical laptop or monitor speakers.
studio
Flat, uncolored output for high-fidelity mixing environments.