Skip to main content
196

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Android docs
Data displayAndroid

Image comparison

Compare two images with a controlled reveal and native adjustable slider.

Public APILumenImageComparisonAndroid / Compose

Native example

Use Image comparison

The value is the visible after fraction, clamped to zero through one; nonfinite input falls back to one half. The application owns image loading, errors, cache, fit and descriptions; provide React Native sources, SwiftUI content builders or Compose painters.

Image comparison rendered in the Android phone emulator Lumen playground
Captured exampleAndroid phone emulator
kotlin
LumenImageComparison(
    label = "Compare edits", before = beforePainter, after = afterPainter,
    value = position, onValueChange = { position = it },
    beforeLabel = "Before", afterLabel = "After"
)

Reference

Public API

The primary shared and platform-specific options exposed by LumenImageComparison.

APIValues or typeDefaultDescription
labelStringRequiredNames the comparison adjustment.
before / afterPainterRequiredProvides native images with application-owned loading.
value / onValueChangeFloat / (Float) -> UnitRequiredControls the visible after fraction from zero through one.
modifierModifierModifierApplies layout.
beforeLabel / afterLabelStringBefore / AfterDescribes each image and the adjustment state.
aspectRatioFloat16f / 9fUses ratios from 0.1 through 10; other input falls back to 16:9.
fitLumenImageFitCoverChooses crop or contain behavior for both images.
localeLocaleLocale.getDefault()Formats the visible fraction as a localized percentage.
enabledBooleantrueDisables adjustment while retaining both images.

Native behavior

Design and accessibility

When to use it

The value is the visible after fraction, clamped to zero through one; nonfinite input falls back to one half. The application owns image loading, errors, cache, fit and descriptions; provide React Native sources, SwiftUI content builders or Compose painters.

Accessibility

Exposes a named native slider with localized percentage state for touch, keyboard, and screen-reader adjustment.

Shared component

Available on other platforms

React NativeApple / SwiftUI
Android docsCompose module