RippleConfiguration

class RippleConfiguration


Configuration for ripple appearance, provided using LocalRippleConfiguration. In most cases the default values should be used, for custom design system use cases you should instead build your own custom ripple using createRippleModifierNode. To disable the ripple, provide null using LocalRippleConfiguration.

The ripple configuration is resolved as follows:

  • LocalRippleThemeConfiguration provides the highest-level theming configuration for ripples, including whether the focus indication is drawn by inset focus rings.

  • LocalRippleConfiguration provides hierarchical per-ripple configuration for ripple, including disabling ripples and their indications. This takes next highest priority.

  • ripple parameters allow specifying configuration for individual indication callsites in components.

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.unit.dp
import androidx.wear.compose.material3.Button
import androidx.wear.compose.material3.LocalRippleConfiguration
import androidx.wear.compose.material3.LocalRippleThemeConfiguration
import androidx.wear.compose.material3.MaterialTheme
import androidx.wear.compose.material3.RippleConfiguration
import androidx.wear.compose.material3.RippleThemeConfiguration
import androidx.wear.compose.material3.SwitchButton
import androidx.wear.compose.material3.Text

// Customize the focus ring stroke sizes through the theme configuration.
CompositionLocalProvider(
    LocalRippleThemeConfiguration provides
        RippleThemeConfiguration(
            RippleThemeConfiguration.Focus.InsetRing(
                outerStrokeInset = 0.dp,
                outerStrokeWidth = 3.dp,
                innerStrokeInset = 0.dp,
                innerStrokeWidth = 6.dp,
            )
        )
) {
    Column(
        modifier = Modifier.fillMaxSize(),
        verticalArrangement = Arrangement.spacedBy(4.dp, Alignment.CenterVertically),
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        // Button is a standard Wear Material3 component that supports focus rings internally.
        Button(onClick = { /* Do something */ }, label = { Text("Button") })

        // SwitchButton is also a standard component that supports focus rings internally.
        // We override its focus ring colors here.
        CompositionLocalProvider(
            LocalRippleConfiguration provides
                RippleConfiguration(
                    focus =
                        RippleConfiguration.Focus.InsetRing(
                            outerStrokeColor = MaterialTheme.colorScheme.tertiary,
                            innerStrokeColor = MaterialTheme.colorScheme.onTertiary,
                        )
                )
        ) {
            SwitchButton(
                checked = true,
                onCheckedChange = { /* Do something */ },
                label = { Text("SwitchButton") },
            )
        }
    }
}

Summary

Nested types

The configuration options for the focus indication for RippleConfiguration.

An inset ring focus indication.

An opacity-based focus indication.

Public constructors

Configuration for ripple appearance, provided using LocalRippleConfiguration.

RippleConfiguration(color: Color, rippleAlpha: RippleAlpha?)

This function is deprecated. Use other configuration options in RippleThemeConfiguration, RippleConfiguration and ripple.

Configuration for ripple appearance, provided using LocalRippleConfiguration.

Public functions

open operator Boolean
equals(other: Any?)
open Int
open String

Public properties

Color

the color override for the ripple.

RippleConfiguration.Focus?

the focus indication override for this ripple.

RippleAlpha?

This property is deprecated. Use other configuration options in RippleThemeConfiguration, RippleConfiguration and ripple.

Public constructors

RippleConfiguration

Added in 1.8.0-alpha03
RippleConfiguration(color: Color = Color.Unspecified)

Configuration for ripple appearance, provided using LocalRippleConfiguration. In most cases the default values should be used, for custom design system use cases you should instead build your own custom ripple using createRippleModifierNode. To disable the ripple, provide null using LocalRippleConfiguration.

Parameters
color: Color = Color.Unspecified

the color override for the ripple. If Color.Unspecified, then the default color from the theme will be used instead. Note that if the ripple has a color explicitly set with the parameter on ripple, that will always be used instead of this value.

RippleConfiguration

Added in 1.6.0
Deprecated in 1.8.0-alpha03
RippleConfiguration(
    color: Color = Color.Unspecified,
    rippleAlpha: RippleAlpha? = null
)

Configuration for ripple appearance, provided using LocalRippleConfiguration. In most cases the default values should be used, for custom design system use cases you should instead build your own custom ripple using createRippleModifierNode. To disable the ripple, provide null using LocalRippleConfiguration.

Parameters
color: Color = Color.Unspecified

the color override for the ripple. If Color.Unspecified, then the default color from the theme will be used instead. Note that if the ripple has a color explicitly set with the parameter on ripple, that will always be used instead of this value.

rippleAlpha: RippleAlpha? = null

the RippleAlpha override for this ripple. If null, then the default alpha will be used instead.

RippleConfiguration

Added in 1.8.0-alpha03
RippleConfiguration(
    focus: RippleConfiguration.Focus?,
    color: Color = Color.Unspecified
)

Configuration for ripple appearance, provided using LocalRippleConfiguration. In most cases the default values should be used, for custom design system use cases you should instead build your own custom ripple using createRippleModifierNode. To disable the ripple, provide null using LocalRippleConfiguration.

Parameters
focus: RippleConfiguration.Focus?

the focus indication override for this ripple. If null, then the default indication style will be used instead. This will only be applied if the style of focus indication matches the one set by LocalRippleThemeConfiguration (opacity vs inset focus ring).

color: Color = Color.Unspecified

the color override for the ripple. If Color.Unspecified, then the default color from the theme will be used instead. Note that if the ripple has a color explicitly set with the parameter on ripple, that will always be used instead of this value.

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

color

val color: Color

the color override for the ripple. If Color.Unspecified, then the default color from the theme will be used instead. Note that if the ripple has a color explicitly set with the parameter on ripple, that will always be used instead of this value.

focus

Added in 1.8.0-alpha03
val focus: RippleConfiguration.Focus?

the focus indication override for this ripple. If null, then the default indication style will be used instead. This will only be applied if the style of focus indication matches the one set by LocalRippleThemeConfiguration (opacity vs inset focus ring). If the style doesn't match, then this configuration will be ignored and the default indication style will be used instead.

rippleAlpha

Added in 1.6.0
Deprecated in 1.8.0-alpha03
val rippleAlpha: RippleAlpha?

The RippleAlpha used to configure the opacity levels of the per-ripple configuration.