Comparison Slider
Drag a divider to reveal a before/after comparison of two layers.
Import
tsx
import { ComparisonSlider } from "@cronus-ui/ui";
bash
npx cronus-ui add comparison-slider
Examples
.cronus
The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.
default.cronus
app "audit-fixtures" {
port 5176
}
style {
preset aurora
theme dark
}
component ComparisonSliderDefault layout:inline style:comparison-slider {
aria-label:"Comparison"
label "Comparison"
text "Before"
text "After"
}
page "/audit/comparison-slider/default" type:custom {
use ComparisonSliderDefault
}
API Reference
Generated from the component's exported types.
ComparisonSliderProps
Extends Omit<HTMLAttributes<HTMLDivElement>, "onChange">
| Prop | Type | Default | Description |
|---|---|---|---|
before* | ReactNode | — | Content shown on the left, revealed by the clip (typically the "before" image). |
after* | ReactNode | — | Content shown as the full base layer (typically the "after" image). |
defaultPosition | number | 50 | Initial divider position as a percentage (0–100). Uncontrolled. |
position | number | — | Controlled divider position as a percentage (0–100). |
onPositionChange | (position: number) => void | — | Called with the next position when the divider moves. |
aria-label | string | — | Accessible name for the divider handle. |
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |