Compare Reveal
motiq/compare-revealFreeComponent
A before/after comparator whose divider chases the pointer through a spring (k=140, c=18, ζ≈0.76) so the lag reads as elastic resistance, demonstrates itself once on first viewport entry (50 → 96 → 4 → 50 over 2.6s), and snaps home on double-click. Coral signature handle; real slider semantics with 2% / Shift 10% arrow steps.
Live preview
live · rendered by the registry
Rendered by motiq on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.motiq.dev/r/compare-reveal.jsonSource
1"use client";23import * as React from "react";45import { cn } from "@/lib/utils";6import { useControllableState, useReducedMotion, useVisibilityPause } from "@/lib/motiq";78/* -------------------------------------------------------------------------- */9/* Types */10/* -------------------------------------------------------------------------- */1112/** A comparison side: an image descriptor, or any node you render yourself. */13export type CompareRevealSource = React.ReactNode | { src: string; alt?: string };1415export interface CompareRevealProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {16 /** The "before" side, revealed from the left edge to the divider. */17 before: CompareRevealSource;18 /** The "after" side, filling the rest of the frame. */19 after: CompareRevealSource;20 /** Uncontrolled starting divider position, 0–100. */21 defaultPosition?: number;22 /** Controlled divider position, 0–100. */23 position?: number;24 /** Fires with the new target percentage on drag, key, or snap. */25 onPositionChange?: (pct: number) => void;26 /** Play the one-time self-demonstrating sweep on first viewport entry. */27 introSweep?: boolean;28 /** Divider spring — 140/18 (ζ≈0.76) reads as elastic resistance. */29 stiffness?: number;30 damping?: number;31 /** Corner chips, [before, after]. */32 labels?: [string, string];33 /** Percentage the divider snaps to on double-click. */34 snapOnDoubleClick?: number;35 /** Force the still variant regardless of system preference. */36 reducedMotion?: boolean;37 /** Stop the rAF loop while scrolled offscreen or the tab is hidden. */38 pauseWhenHidden?: boolean;39}4041/* -------------------------------------------------------------------------- */42/* Constants (Motion Lab ship spec) */43/* -------------------------------------------------------------------------- */4445const SPRING_K = 140;46const SPRING_C = 18;47/** Intro sweep: 50 → 96 → 4 → 50 over 2.6s, cubic ease per leg. */48const SWEEP_SECONDS = 2.6;49const KEY_STEP = 2;50const KEY_STEP_LARGE = 10;51/** A side's chip fades out once that side narrows past this percentage. */52const LABEL_FADE = 12;5354const clamp = (v: number, lo: number, hi: number) => (v < lo ? lo : v > hi ? hi : v);55const lerp = (a: number, b: number, t: number) => a + (b - a) * t;56// … truncated
What it pulls in
Other registry items
Files it writes
More from motiq
All 100 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Activity Streamactivity-stream | motiq | Components | Free | 1 dep | |
| Adaptive Safe-Zone Gridadaptive-safe-zone-grid | motiq | Components | Free | no deps | |
| Agent Run Timelineagent-run-timeline | motiq | Components | Free | 1 dep | |
| AI Response Streamai-response-stream | motiq | Components | Free | 1 dep | |
| Animated Accordionanimated-accordion | motiq | Components | Free | 2 deps | |
| Animated Buttonanimated-button | motiq | Components | Free | 1 dep | |
| Animated Dialoganimated-dialog | motiq | Components | Free | 2 deps | |
| Animated Gridanimated-grid | motiq | Components | Free | 2 deps |
