Loading preview
Cards arranged in a ring that turns in 3D, with buttons, arrow keys and announcements.
A before/after slider with a draggable divider that also works with the keyboard.
npx shadcn@latest add @venusui/image-compareRun this in a project set up with shadcn. If you haven’t set it up yet, run npx shadcn@latest init first.
Paths use the default shadcn aliases. The CLI follows the aliases in your components.json.
@/components/ui/image-compare.tsxThe code behind the preview above.
image-compare-demo.tsx
import { ImageCompare } from "@/components/ui/image-compare"
function Mock({ dark }: { dark?: boolean }) {
return (
<div className={dark ? "size-full bg-zinc-950 p-6 text-zinc-50" : "size-full bg-zinc-50 p-6 text-zinc-950"}>
<div className="h-3 w-24 rounded bg-current opacity-80" />
<div className="mt-4 grid grid-cols-3 gap-3">
{[0, 1, 2, 3, 4, 5].map((i) => (
<div key={i} className="h-16 rounded-md border border-current/15 bg-current/5" />
))}
</div>
</div>
)
}
export default function ImageCompareDemo() {
return (
<ImageCompare
className="max-w-xl"
beforeLabel="Light"
afterLabel="Dark"
before={<Mock />}
after={<Mock dark />}
/>
)
}
| Prop | Type | Default | Description |
|---|---|---|---|
| before | ReactNode | — | Left layer, e.g. an <img>. Required. |
| after | ReactNode | — | Right layer. Required. |
| beforeLabel | string | "Before" | Label shown on the left and used in the slider’s name. |
| afterLabel | string | "After" | Label shown on the right. |
| defaultPosition | number | 50 | Starting divider position, 0–100. |
| className | string | — | Classes for the frame, e.g. a different aspect ratio. |
Only the props above.
cn helper at @/lib/utils. No other dependencies.className="size-full object-cover" and meaningful alt text.className="aspect-square" for square images.object-cover and size-full to both images so they fill the frame the same way.Unknown registry "@venusui"npx shadcn@latest), install by URL, or register it with its address: npx shadcn@latest registry add @venusui=https://venusui.com/r/{name}.json.No components.json foundnpx shadcn@latest init in your project first.Cards arranged in a ring that turns in 3D, with buttons, arrow keys and announcements.
A station clock whose needle waits at twelve; drag the minute hand to set it by hand.
A card that tilts in 3D toward the pointer with spring physics.