SlideToUnlock

fun SlideToUnlock(isSlided: Boolean, onSlideCompleted: () -> Unit = {}, modifier: Modifier = Modifier, colors: SlideToUnlockColors = DefaultSlideToUnlockColors(), hintTexts: HintTexts = HintTexts.defaultHintTexts(), trackShape: Shape = RoundedCornerShape(percent = 50), thumbSize: DpSize = DpSize(ThumbSize, ThumbSize), fractionalThreshold: Float = 0.85f, paddings: PaddingValues = PaddingValues(SlideToUnlockDefaults.Paddings), hintPaddings: PaddingValues = PaddingValues(start = thumbSize.width, end = thumbSize.width), onSlideFractionChanged: (Float) -> Unit = {}, orientation: SlideOrientation = SlideOrientation.Horizontal, thumb: @Composable BoxScope.(isSlided: Boolean, slideFraction: Float, colors: SlideToUnlockColors, size: DpSize, orientation: SlideOrientation) -> Unit = { slided, _, _, size, orient -> SlideToUnlockDefaults.Thumb( modifier = Modifier.size(thumbSize), isSlided = slided, colors = colors, thumbSize = thumbSize, orientation = orient, ) }, hint: @Composable BoxScope.(isSlided: Boolean, slideFraction: Float, hintTexts: HintTexts, colors: SlideToUnlockColors, paddings: PaddingValues, orientation: SlideOrientation) -> Unit = { slided, fraction, _, _, paddings, orient -> SlideToUnlockDefaults.Hint( modifier = Modifier.align(Alignment.Center), slideFraction = fraction, hintTexts = hintTexts, isSlided = slided, colors = colors, paddingValues = hintPaddings, orientation = orient, ) })

A fully customizable "slide-to-unlock" UI component for Jetpack Compose.

This component displays a track with a draggable thumb. The user can slide the thumb from the start to the end to trigger an action. The component supports a loading state where the thumb is locked at the end and displays a progress indicator.

Supports horizontal (default) and vertical orientations via SlideOrientation.

Parameters

isSlided

Whether the slider has been completed and locked. When true, the thumb is fixed at the end and a loading indicator may be shown.

onSlideCompleted

Invoked when the user successfully completes the slide gesture by dragging the thumb past the fractionalThreshold.

modifier

Modifier to be applied to the layout.

colors

Provides the color scheme for the track, thumb, and hint. Defaults to DefaultSlideToUnlockColors.

hintTexts

Provides the hint messages for both the default and slided states.

trackShape

Defines the shape of the background track. Defaults to a rounded rectangle.

thumbSize

The size of the draggable thumb.

fractionalThreshold

The fraction of the track (from 0.0f to 1.0f) that the user must slide the thumb past to trigger the onSlideCompleted callback. Defaults to 0.85f (85%).

paddings

The external padding values to be applied to the entire component.

hintPaddings

The internal padding values for the hint composable, used to prevent the hint from overlapping with the thumb at its start and end positions.

onSlideFractionChanged

Optional callback invoked with the current slide progress fraction (0f–1f) as the user drags the thumb.

orientation

The direction of the sliding gesture. Defaults to SlideOrientation.Horizontal.

thumb

A composable slot for customizing the draggable thumb. It provides the slide state, current slide fraction, colors, size, and orientation.

hint

A composable slot for customizing the hint text or visuals inside the track. It provides the slide state, current slide fraction, hint texts, colors, paddings, and orientation.