ripple
fun ripple(
bounded: Boolean = true,
radius: Dp = Dp.Unspecified,
color: Color = Color.Unspecified,
focusRingShape: Shape? = null,
enablePressIndication: Boolean = true,
enableFocusIndication: Boolean = true,
enableHoverIndication: Boolean = true,
enableDragIndication: Boolean = true,
): IndicationNodeFactory
Creates a Ripple using the provided values and values inferred from the theme.
A Ripple is a Material implementation of Indication that expresses different Interactions by drawing ripple animations and state layers.
A Ripple responds to PressInteraction.Press by starting a new ripple animation, and responds to other Interactions by showing a fixed state layer with varying alpha values depending on the Interaction.
MaterialTheme provides Ripples using androidx.compose.foundation.LocalIndication, so a Ripple will be used as the default Indication inside components such as androidx.compose.foundation.clickable and androidx.compose.foundation.indication, in addition to Material provided components that use a Ripple as well.
You can also explicitly create a Ripple and provide it to custom components in order to change the parameters from the default, such as to create an unbounded ripple with a fixed size.
To create a Ripple with a manually defined color that can change over time, see the other ripple overload with a ColorProducer parameter. This will avoid unnecessary recompositions when changing the color, and preserve existing ripple state when the color changes.
Parameters
| bounded | If true, ripples are clipped by the bounds of the target layout. Unbounded ripples always animate from the target layout center, bounded ripples animate from the touch position. |
| radius | the radius for the ripple. If Dp.Unspecified is provided then the size will be calculated based on the target layout size. |
| color | the color of the ripple state layers. This color is usually the same color used by the text or iconography in the component. This color will then have RippleDefaults.RippleAlpha applied to calculate the final color used to draw the ripple. If Color.Unspecified is provided the color used will be LocalContentColor instead. If inset focus rings are enabled, their colors will be provided by the theme or by an overridden LocalRippleConfiguration. |
| focusRingShape | if specified, the shape of the ripple that the focus ring indication will use, if inset focus ring indications are enabled. If left null, a default shape will be used, which will be a rounded rectangle based on the radius if specified, otherwise it will be just a RectangleShape. This Shape instance must remain the same during the lifetime of the ripple in composition. If the Shape needs to change, delegate from a single instance to the changing shape to preserve the instance requirement. |
| enablePressIndication | if true, this ripple will draw the indication for press interactions. Set this to false to disable drawing any visuals for press interactions in this ripple. |
| enableFocusIndication | if true, this ripple will draw the indication for focus interactions. Set this to false to disable drawing any visuals for focus interactions in this ripple. |
| enableHoverIndication | if true, this ripple will draw the indication for hover interactions. Set this to false to disable drawing any visuals for hover interactions in this ripple. |
| enableDragIndication | if true, this ripple will draw the indication for drag interactions. Set this to false to disable drawing any visuals for drag interactions in this ripple. |
ripple
Deprecated
Maintained for binary compatibility
fun ripple(
bounded: Boolean = true,
radius: Dp = Dp.Unspecified,
color: Color = Color.Unspecified,
): IndicationNodeFactory
Creates a Ripple using the provided values and values inferred from the theme.
A Ripple is a Material implementation of Indication that expresses different Interactions by drawing ripple animations and state layers.
A Ripple responds to PressInteraction.Press by starting a new ripple animation, and responds to other Interactions by showing a fixed state layer with varying alpha values depending on the Interaction.
MaterialTheme provides Ripples using androidx.compose.foundation.LocalIndication, so a Ripple will be used as the default Indication inside components such as androidx.compose.foundation.clickable and androidx.compose.foundation.indication, in addition to Material provided components that use a Ripple as well.
You can also explicitly create a Ripple and provide it to custom components in order to change the parameters from the default, such as to create an unbounded ripple with a fixed size.
To create a Ripple with a manually defined color that can change over time, see the other ripple overload with a ColorProducer parameter. This will avoid unnecessary recompositions when changing the color, and preserve existing ripple state when the color changes.
Parameters
| bounded | If true, ripples are clipped by the bounds of the target layout. Unbounded ripples always animate from the target layout center, bounded ripples animate from the touch position. |
| radius | the radius for the ripple. If Dp.Unspecified is provided then the size will be calculated based on the target layout size. |
| color | the color of the ripple. This color is usually the same color used by the text or iconography in the component. This color will then have RippleDefaults.RippleAlpha applied to calculate the final color used to draw the ripple. If Color.Unspecified is provided the color used will be LocalContentColor instead. |
ripple
fun ripple(
color: ColorProducer,
bounded: Boolean = true,
radius: Dp = Dp.Unspecified,
focusRingShape: Shape? = null,
enablePressIndication: Boolean = true,
enableFocusIndication: Boolean = true,
enableHoverIndication: Boolean = true,
enableDragIndication: Boolean = true,
): IndicationNodeFactory
Creates a Ripple using the provided values and values inferred from the theme.
A Ripple is a Material implementation of Indication that expresses different Interactions by drawing ripple animations and state layers.
A Ripple responds to PressInteraction.Press by starting a new ripple animation, and responds to other Interactions by showing a fixed state layer with varying alpha values depending on the Interaction.
MaterialTheme provides Ripples using androidx.compose.foundation.LocalIndication, so a Ripple will be used as the default Indication inside components such as androidx.compose.foundation.clickable and androidx.compose.foundation.indication, in addition to Material provided components that use a Ripple as well.
You can also explicitly create a Ripple and provide it to custom components in order to change the parameters from the default, such as to create an unbounded ripple with a fixed size.
To create a Ripple with a static color, see the ripple overload with a Color parameter. This overload is optimized for Ripples that have dynamic colors that change over time, to reduce unnecessary recompositions.
Parameters
| color | the color of the ripple. This color is usually the same color used by the text or iconography in the component. This color will then have RippleDefaults.RippleAlpha applied to calculate the final color used to draw the ripple. If you are creating this ColorProducer outside of composition (where it will be automatically remembered), make sure that its instance is stable (such as by remembering the object that holds it), or remember the returned ripple object to make sure that ripple nodes are not being created each recomposition. If inset focus rings are enabled, their colors will * be provided by the theme or by an overridden LocalRippleConfiguration. |
| bounded | If true, ripples are clipped by the bounds of the target layout. Unbounded ripples always animate from the target layout center, bounded ripples animate from the touch position. |
| radius | the radius for the ripple. If Dp.Unspecified is provided then the size will be calculated based on the target layout size. |
| focusRingShape | if specified, the shape of the ripple that the focus ring indication will use, if inset focus ring indications are enabled. If left null, a default shape will be used, which will be a rounded rectangle based on the radius if specified, otherwise it will be just a RectangleShape. This Shape instance must remain the same during the lifetime of the ripple in composition. If the Shape needs to change, delegate from a single instance to the changing shape to preserve the instance requirement. |
| enablePressIndication | if true, this ripple will draw the indication for press interactions. Set this to false to disable drawing any visuals for press interactions in this ripple. |
| enableFocusIndication | if true, this ripple will draw the indication for focus interactions. Set this to false to disable drawing any visuals for focus interactions in this ripple. |
| enableHoverIndication | if true, this ripple will draw the indication for hover interactions. Set this to false to disable drawing any visuals for hover interactions in this ripple. |
| enableDragIndication | if true, this ripple will draw the indication for drag interactions. Set this to false to disable drawing any visuals for drag interactions in this ripple. |
ripple
Deprecated
Maintained for binary compatibility
fun ripple(
color: ColorProducer,
bounded: Boolean = true,
radius: Dp = Dp.Unspecified,
): IndicationNodeFactory
Creates a Ripple using the provided values and values inferred from the theme.
A Ripple is a Material implementation of Indication that expresses different Interactions by drawing ripple animations and state layers.
A Ripple responds to PressInteraction.Press by starting a new ripple animation, and responds to other Interactions by showing a fixed state layer with varying alpha values depending on the Interaction.
MaterialTheme provides Ripples using androidx.compose.foundation.LocalIndication, so a Ripple will be used as the default Indication inside components such as androidx.compose.foundation.clickable and androidx.compose.foundation.indication, in addition to Material provided components that use a Ripple as well.
You can also explicitly create a Ripple and provide it to custom components in order to change the parameters from the default, such as to create an unbounded ripple with a fixed size.
To create a Ripple with a static color, see the ripple overload with a Color parameter. This overload is optimized for Ripples that have dynamic colors that change over time, to reduce unnecessary recompositions.
Parameters
| color | the color of the ripple. This color is usually the same color used by the text or iconography in the component. This color will then have RippleDefaults.RippleAlpha applied to calculate the final color used to draw the ripple. If you are creating this ColorProducer outside of composition (where it will be automatically remembered), make sure that its instance is stable (such as by remembering the object that holds it), or remember the returned ripple object to make sure that ripple nodes are not being created each recomposition. |
| bounded | If true, ripples are clipped by the bounds of the target layout. Unbounded ripples always animate from the target layout center, bounded ripples animate from the touch position. |
| radius | the radius for the ripple. If Dp.Unspecified is provided then the size will be calculated based on the target layout size. |