The sound layer your product deserves

852 interaction sounds, synthesized in the browser with the Web Audio API. No audio files, no dependencies, nothing to load.

npm install sonic-flow
View on GitHub

Click a pad, or press 1–9 on your keyboard.Tap a pad to hear it.

Sounds
852
Categories
27
Gzipped, all sounds
<20 kB
Dependencies
0

Sounds

Click any sound to hear it, then use the arrow keys to audition its neighbours. Copy gives you the exact play() call.

    Missing a sound? Request one on GitHub.

    One attribute. Instant feedback.

    Add a data-sf-* attribute to any element and call bind() once. These three are live.

    play(liked ? "like" : "unlike")

    A distinct cue for each state, fired from your own handler.

    data-sf-toggle

    Alternates between toggle-on and toggle-off. Works on any checkbox or switch.

    data-sf-press data-sf-release

    A paired down and up sound, like pressing a physical key.

    Ship sound in under a minute.

    1. Install the package

      npm install sonic-flow
    2. Tag your elements

      Add data-sf-* to anything interactive and call bind() once after the page loads.

    3. Or play on demand

      Call play("name") from any handler. Names are exactly what you see in the library above.

    <!-- Tag any element with a behavior -->
    <button data-sf-press data-sf-release>Save</button>
    <a href="/docs" data-sf-hover="hover-soft">Docs</a>
    <input type="checkbox" data-sf-toggle>
    <button data-sf="success">Publish</button>

    API

    Five functions and a handful of attributes. That’s the whole surface.

    Functions

    • play(name, options?)

      Plays a sound by name. Pass { volume } (0 to 1) to override the master volume for that call.

    • bind(options?)

      Wires every data-sf-* element on the page. Call it once when the DOM is ready. { volume } also sets the master volume.

    • setVolume(value)

      Sets the master volume, from 0 to 1. The default is 0.7.

    • setPitch(semitones)

      Shifts every sound up or down. 0 is the original pitch.

    • getSounds()

      Returns an array with the name of every sound.

    Attributes

    AttributePlays onDefault sound
    data-sf-hoverPointer enterhover
    data-sf-pressMouse down, touch startpress
    data-sf-releaseMouse up, touch endrelease
    data-sf-toggleClick, alternatingtoggle-on / toggle-off
    data-sf-focusFocusfocus
    data-sf-blurBlurblur
    data-sf="name"ClickThe named sound

    Hover, press and release take a sound name as their value, for example data-sf-hover="hover-soft".

    Sounds stay silent for visitors who have prefers-reduced-motion turned on. Loaded from a CDN, the same functions are on window.SonicFlow.