Skip to main content
196

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
React Native docs
Data displayReact Native

Image comparison

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

Public APILumenImageComparisonReact Native

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.

View captured React Native example
Image comparison rendered in the Expo web renderer Lumen playground
Captured exampleExpo web renderer
tsx
import { useState } from 'react'
import { LumenImageComparison } from '@santi020k/lumen-react-native'

export function CompareEdits() {
  const [position, setPosition] = useState(0.5)
  return <LumenImageComparison label="Compare edits"
    before={require('./before.png')} after={require('./after.png')}
    value={position} onValueChange={setPosition}
    beforeLabel="Before" afterLabel="After" />
}

Reference

Public API

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

APIValues or typeDefaultDescription
labelstringRequiredNames the adjustable reveal.
before / afterImageSourcePropTypeRequiredApplication-owned sources; provide assets and loading policy.
value / onValueChangenumber / (number) => voidRequiredControls the visible after fraction, zero through one.
beforeLabel / afterLabelstringBefore / AfterLocalizes image labels and adjustment state.
aspectRationumber16 / 9Accepts 0.1 through 10; otherwise uses 16:9.
fitLumenImageFitcoverChooses cover or contain image behavior.
localestringundefinedFormats the percentage.
enabledbooleantrueDisables adjustment while preserving images.
style / View propsViewPropsundefinedApplies native layout and accessibility props.

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

Apple / SwiftUIAndroid / Compose
React Native docsNative primitives