androidx.compose.material3
ripple
Function
No hand-written docs yet.
Creates a Ripple using the provided values and values inferred from the theme.
Form 1
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
bounded: BooleanOptional
bounded: BooleanOptionalDefault: true
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: DpOptional
radius: DpOptionalDefault: Dp.Unspecified
the radius for the ripple. If Dp.Unspecified is provided then the size will be calculated based on the target layout size.
color: ColorOptional
color: ColorOptionalDefault: Color.Unspecified
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: Shape?OptionalSince 1.12
focusRingShape: Shape?OptionalSince 1.12Default: null
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: BooleanOptionalSince 1.12
enablePressIndication: BooleanOptionalSince 1.12Default: true
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: BooleanOptionalSince 1.12
enableFocusIndication: BooleanOptionalSince 1.12Default: true
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: BooleanOptionalSince 1.12
enableHoverIndication: BooleanOptionalSince 1.12Default: true
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: BooleanOptionalSince 1.12
enableDragIndication: BooleanOptionalSince 1.12Default: true
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.
Form 2
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
color: ColorProducerRequired
color: ColorProducerRequiredthe 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.
Same as above: bounded, radius, focusRingShape, enablePressIndication, enableFocusIndication, enableHoverIndication, enableDragIndication.
Library docs
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.