Fine-tune light, shadows, borders, neumorphic
Light and shadows
Borders
Neumorphic
Display

Compare <pm-compare>

Compare: two pictures in one frame with a handle to drag between them, for before and after, old and new.

Full screen
The dashboard in the light theme The dashboard in the dark theme

Props

<script type="module"> import '@prismora/css'; import '@prismora/elements/compare'; </script> <pm-compare label="Light and dark theme" before-label="Light" after-label="Dark" style="inline-size: min(100%, 32rem)"> <img slot="before" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 90'%3E%3Cdefs%3E%3ClinearGradient id='g' x2='1' y2='1'%3E%3Cstop stop-color='%237c5cff'/%3E%3Cstop offset='1' stop-color='%23ff7ab6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='160' height='90' fill='url(%23g)'/%3E%3Ccircle cx='118' cy='30' r='14' fill='%23fff' opacity='.85'/%3E%3Cpath d='M0 90l45-48 30 30 22-18 63 36z' fill='%23fff' opacity='.35'/%3E%3C/svg%3E" alt="The dashboard in the light theme"> <img slot="after" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 90'%3E%3Cdefs%3E%3ClinearGradient id='g' x2='1' y2='1'%3E%3Cstop stop-color='%237c5cff'/%3E%3Cstop offset='1' stop-color='%23ff7ab6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='160' height='90' fill='url(%23g)'/%3E%3Ccircle cx='118' cy='30' r='14' fill='%23fff' opacity='.85'/%3E%3Cpath d='M0 90l45-48 30 30 22-18 63 36z' fill='%23fff' opacity='.35'/%3E%3C/svg%3E" alt="The dashboard in the dark theme" style="filter: invert(1) hue-rotate(180deg)"> </pm-compare>

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

AttributeTypeDefaultDescription
valuenumber50How much of the first picture is shown, 0 to 100 (default 50).
labelstring—Accessible name of the slider, e.g. "Before and after".
stepnumber5How far an arrow key moves the handle (default 5).
before-label
prop: beforeLabel
string—Text shown on the first picture.
after-label
prop: 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

EventReact / Svelte propDescription
pm-inputonPmInputWhile the handle moves. detail.value is 0 to 100.
pm-changeonPmChangeThe handle was released. detail.value is 0 to 100.

Slots

SlotDescription
beforeThe first picture (shown from the start edge to the handle).
afterThe second picture.

CSS parts

PartDescription
::part(base)The frame.
::part(handle)The round handle.