Comparison Slider
Interactive before/after media comparison slider with sub-pixel clip-path polygon slicing and WAI-ARIA keyboard navigation.
Interactive Specification & Studio
120Hz ProMotion
Compositor accelerated
Traditional View
Unaccelerated layout
Quick Start & Consumer Example
Copy-paste ready implementation for React (.tsx). Automatically updates when you modify parameters in the Workbench above.
import React from 'react';
import { ComparisonSlider } from '@/components/ui/ComparisonSlider';
export default function ComparisonDemo() {
return (
<div className="flex min-h-screen items-center justify-center p-8 bg-background">
<div className="w-full max-w-2xl">
<ComparisonSlider
aspectRatio="16/10"
defaultPosition={0.5}
step={0.05}
orientation="horizontal"
before={
<div className="flex size-full flex-col justify-between bg-gradient-to-br from-indigo-950 via-purple-950 to-slate-900 p-8 text-white">
<span className="font-mono text-xs font-bold uppercase tracking-wider text-purple-300">
Legacy Pipeline
</span>
<div>
<h4 className="text-2xl font-bold">Unaccelerated Canvas</h4>
<p className="mt-1 text-sm text-purple-200/70">Standard 60Hz DOM repainting</p>
</div>
</div>
}
after={
<div className="flex size-full flex-col justify-between bg-gradient-to-br from-emerald-950 via-teal-950 to-slate-900 p-8 text-white">
<span className="font-mono text-xs font-bold uppercase tracking-wider text-emerald-400">
Exhuma Kinetic Engine
</span>
<div>
<h4 className="text-2xl font-bold">120Hz ProMotion</h4>
<p className="mt-1 text-sm text-emerald-200/70">Sub-pixel polygon GPU clipping</p>
</div>
</div>
}
/>
</div>
</div>
);
}
Props & Configuration
Exhaustive parameter contract for Comparison Slider. Validated in the live Studio workbench above and statically checked across all 13 ecosystem templates.
| Prop | Type | Default | Description |
|---|---|---|---|
defaultPosition | number | 0.5 | Initial divider split ratio between 0 and 1. |
step | number | 0.05 | Position delta when stepping with arrow keys. |
orientation | select | horizontal | Slider split direction (horizontal or vertical). |
Initial divider split ratio between 0 and 1.
Position delta when stepping with arrow keys.
Slider split direction (horizontal or vertical).
Component Source
Component source definition for React (.tsx). Toggle between the clean wrapper and the standalone ejected engine micro-kernel.
import * as React from 'react';
import * as ComparisonSliderPrimitive from '@exhuma/core';
import { clsx } from 'clsx';
export interface ComparisonSliderProps extends React.ComponentPropsWithoutRef<typeof ComparisonSliderPrimitive.ComparisonSlider> {
className?: string;
}
export const ComparisonSlider = React.forwardRef<HTMLDivElement, ComparisonSliderProps>(
({ className, children, ...props }, ref) => (
<ComparisonSliderPrimitive.ComparisonSlider
ref={ref}
className={clsx(
'relative overflow-hidden rounded-2xl border border-border select-none w-full max-w-2xl mx-auto',
className
)}
{...props}
>
{children}
</ComparisonSliderPrimitive.ComparisonSlider>
)
);
ComparisonSlider.displayName = 'ComparisonSlider';
Lifecycle Safety & Performance
Engineered for high-frequency user interactions with zero memory leaks.
Deterministic Cleanup
GPU Compositor Acceleration
will-change: transform without triggering browser layout recalculations.Accessibility Considerations
Fully compliant with WCAG guidelines and respects user motion preferences.
prefers-reduced-motion Support
prefers-reduced-motion: reduce enabled in their operating system, Exhuma components automatically disable 3D gyroscope tilt and spring animations, rendering static accessible content.