# @inklu/audio > A synthesized sound library for interfaces. No audio files, no dependencies: every sound is generated on the fly with the Web Audio API. - Install: `npm install @inklu/audio` - Agent skill: `npx skills add nkurunziza-saddy/inklu --skill inklu-audio` ## Docs - [Full reference](https://inklu.saddy.me/audio/llms-full.txt): every export, option and pattern, as Markdown - [Documentation](https://inklu.saddy.me/audio): Install, a live demo, the quick start and a setup prompt for agents - [Studio](https://inklu.saddy.me/audio/studio): Build a custom theme with sliders and copy the code ## Optional - [Source](https://github.com/nkurunziza-saddy/inklu/tree/main/packages/audio) - [npm](https://www.npmjs.com/package/@inklu/audio) ## Setup prompt Add synthesized UI sound effects using the `@inklu/audio` package. Do not invent APIs. If something here is ambiguous, read https://inklu.saddy.me/audio/llms-full.txt before guessing. ### 1. Install `npm install @inklu/audio` No extra dependencies. Every sound is generated on-demand with the Web Audio API — no audio files, no CDN requests. ### 2. Start the attribute listener Call `observe()` once, in the browser. In React, render this client component once in the root layout: ```tsx "use client"; import { observe } from "@inklu/audio"; import { useEffect } from "react"; export function Sounds() { useEffect(() => observe(), []); // observe() returns its own cleanup return null; } ``` It installs delegated listeners that play the sound named on whatever element is clicked, hovered or focused, including elements added later, and unlocks audio on the first click. ### 3. Declarative usage (recommended) Add `data-sound` attributes to interactive elements: ```tsx
Muted subtree — no sounds inside
``` Sound ids: `tap`, `click`, `key-press`, `hover`, `toggle-on`, `toggle-off`, `checkbox`, `select`, `deselect`, `tab-switch`, `expand`, `collapse`, `page-enter`, `page-exit`, `turn:forward`, `turn:back`, `success`, `error`, `warning`, `notification`, `info`, `deny`, `copy`, `send`, `delete`, `erase`, `undo`, `pop`, `swoosh`, `slide`. Use no others. ### 4. Programmatic usage Import the engine singleton for imperative control: ```tsx import { engine } from "@inklu/audio"; // Trigger sounds engine.play("tap"); engine.play("success"); // Configure engine engine.setVolume(0.7); engine.setTheme("mechanical"); engine.setEnabled(true); ``` ### 5. Agent setup pattern When instrumenting an existing codebase, follow this checklist: - Buttons & links: `data-sound="tap"` or `data-sound="click"` - Interactive elements: `data-sound-hover="hover"` - Text inputs & selects: `data-sound-focus="select"` - Checkboxes & switches: `data-sound={checked ? "toggle-off" : "toggle-on"}` - Destructive actions: `data-sound="delete"` - Clear buttons (a field, a filter, "clear all"): `data-sound="erase"` - Toast/alert confirmations: programmatic `engine.play("success")` or `engine.play("error")` ### Constraints - Call `observe()` and `engine.play()` from client code only (an effect or an event handler), never from a Server Component. - Browsers keep audio locked until the first user gesture, so nothing plays before it. This is expected; if sounds only come from code, call `engine.prime()` in the first click or key handler. ### Before you finish Verify `observe()` runs once from the root layout, then test at least one click, hover, and focus interaction to confirm sounds are audible.