Display
Compare <pm-compare>
Compare: two pictures in one frame with a handle to drag between them, for before and after, old and new.
Overview
Put the first picture in the before slot and the second in after; give both the same size. Drag anywhere on the picture, or use the arrow keys (the handle is a slider: Home and End jump to either side).
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
value | number | 50 | How much of the first picture is shown, 0 to 100 (default 50). |
label | string | — | Accessible name of the slider, e.g. "Before and after". |
step | number | 5 | How far an arrow key moves the handle (default 5). |
before-labelprop: beforeLabel | string | — | Text shown on the first picture. |
after-labelprop: afterLabel | string | — | Text shown on the second picture. |
Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.
Events
| Event | React / Svelte prop | Description |
|---|---|---|
pm-input | onPmInput | While the handle moves. detail.value is 0 to 100. |
pm-change | onPmChange | The handle was released. detail.value is 0 to 100. |
Slots
| Slot | Description |
|---|---|
before | The first picture (shown from the start edge to the handle). |
after | The second picture. |
CSS parts
| Part | Description |
|---|---|
::part(base) | The frame. |
::part(handle) | The round handle. |