Put the edited image in ComparisonAfter, the original in ComparisonBefore, and add the handle that people drag.
The sample also uses Image. One command adds them with this item:
color-grade.tsx
Comparison
<div>| Prop | Type | Default | Description | |||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| value | number | — | The share of the before, 0–100 (controlled). | |||||||||||||||||||||||
| default | number | 50 | The share of the before at the start, 0–100 (uncontrolled). Default 50. | |||||||||||||||||||||||
| on | — | Runs on every change, with the new share of the before and why it changed: the Base UI Slider reasons (keyboard, input-change), plus the ones of the pointer layer of this component: track-press (a mouse press on the frame), drag, swipe (a finger across the frame), tap (a finger tap on the frame), and hover. | ||||||||||||||||||||||||
| on | — | Runs when a change ends: a key press, a pointer release, a tap. The same reasons; hover never commits (it has no end). The details are { reason, event } only: a change cannot be canceled from here (make the Comparison controlled to keep a value). | ||||||||||||||||||||||||
| orientation | "horizontal""vertical" | "horizontal" | horizontal (default): a vertical divider, the before on the start side. vertical: the before on top. | |||||||||||||||||||||||
| interaction | "drag""handle""hover" | "drag" | How a pointer moves the divider. Keys and touch work the same in every mode. - drag (default): a press anywhere on the frame moves the divider to the pointer, and the drag goes on. - handle: only the handle (the line and the knob) takes a press, so the pictures can hold links, a video with controls, or text to select. - hover: as drag, and a mouse over the frame moves the divider with no press. | |||||||||||||||||||||||
| mode | "side-by-side""single""split" | "split" | How the two versions show (the "Before and After" upgrade of the AI category). - split (default): one frame cut by a divider (the handle). - single: one version at a time, in one frame. value 100 shows the before and 0 the after; a change wipes across on the panel clock. A press and hold on the frame shows the other version until the release (the "hold to compare" of image editors). The handle does not show: put a switch (Tabs "Before" and "After") outside the frame as the keyboard path. - side-by-side: two frames next to each other (one above the other when vertical), 8px apart, each at ratio. No divider, no pointer, no keys; the value does nothing. | |||||||||||||||||||||||
| ratio | number | — | The ratio of one picture (width over height, 16 / 9). Split and single: the frame takes it (an aspect-* class in className also works and wins). Side by side: each frame takes it (default 16 / 9), because the root holds two frames and has no ratio of its own. | |||||||||||||||||||||||
| class | string | — | ||||||||||||||||||||||||
| style | CSSProperties | — | ||||||||||||||||||||||||
From Base UISlider.RootBase UI docs | ||||||||||||||||||||||||||
| disabled | boolean | false | Whether the slider should ignore user interaction. | |||||||||||||||||||||||
| format | NumberFormatOptions | — | Options to format the value. | |||||||||||||||||||||||
| locale | LocalesArgument | — | The locale used by Intl.NumberFormat when formatting the value. Defaults to the user's runtime locale. | |||||||||||||||||||||||
| ||||||||||||||||||||||||||
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. | |||||||||||||||||||||||
ComparisonBefore
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
ComparisonAfter
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
ComparisonHandle
<div>| Prop | Type | Default | Description | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| class | string | — | |||||||||||||||||||||||||||||||||||
| children | ReactNode | — | The knob content. Default: ChevronsLeftRight, or ChevronsUpDown when vertical. | ||||||||||||||||||||||||||||||||||
| get | defaultValueText | The value text for screen readers, from the share of the before. Default "40% before, 60% after". | |||||||||||||||||||||||||||||||||||
From Base UISlider.ThumbBase UI docs | |||||||||||||||||||||||||||||||||||||
| disabled | boolean | false | Whether the thumb should ignore user interaction. | ||||||||||||||||||||||||||||||||||
| aria-valuetext | string | — | A string value forwarded to the aria-valuetext attribute of the input. Ignored when getAriaValueText is provided. | ||||||||||||||||||||||||||||||||||
| get | ((index: number) => string) | null | — | A function which returns a string value for the aria-label attribute of the input. | ||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. | ||||||||||||||||||||||||||||||||||
ComparisonLabel
<span>| Prop | Type | Default | Description |
|---|---|---|---|
| placement | "bottom""top" | "top" | top (default) or bottom, for a horizontal Comparison. The before label takes the start corner, the after label the end corner. Vertical: the before label is at the top start and the after label at the bottom start, whatever this says. |
| ...props | <span> attributes | — | Every other attribute goes to the <span>, with a ref. |
ComparisonCaption
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| mode | "side-by-side""single""split" | "split" | The mode of the Comparison under it, so each name sits over its version: split (default) puts the first name at the start and the last at the end; side-by-side puts each over its frame (two columns, 8px apart); single keeps the names together at the start. |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
| Arrow keys | Moves the divider one step. |
|---|---|
| HomeorEnd | Moves the divider to the start or the end. |





