SoundEffect


Interface representing the capability to play sound effects on user interaction.

This is used primarily to play interaction sound effects for click gestures.

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.SoundEffectOnInteraction
import androidx.compose.ui.unit.dp

Column(modifier = Modifier.padding(16.dp)) {
    Text("Standard Clickable (Has Sound):")
    Button(onClick = {}) { Text("Click me") }

    Text("\nDisabled Sound Feedback:")
    SoundEffectOnInteraction(enabled = false) { Button(onClick = {}) { Text("Silent Button") } }
}
See also
LocalSoundEffect

Summary

Public functions

Unit

Plays a click sound effect.

Cmn

Public functions

playClickSound

fun playClickSound(): Unit

Plays a click sound effect.

This method triggers the standard click sound effect, provided it is supported by the platform, enabled by the user's system, and has not been silenced or customized via SoundEffectOnInteraction.