Loading component…
Loading component…
Content that blurs out and in as it changes, with the box morphing between sizes
To reuse this local React demo, copy all files from the Code tab into the same folder, then import BlurCrossfade from ./blur-crossfade.
import { BlurCrossfade } from "@/components/ui/blur-crossfade";
export function SaveButton({ status }) {
return (
<button>
<BlurCrossfade id={status} morph="both" as="span">
{status === "saving" ? "Saving…" : status === "saved" ? "Saved" : "Save"}
</BlurCrossfade>
</button>
);
}
// Height glides between messages of different length
<BlurCrossfade id={step}>
<p>{steps[step]}</p>
</BlurCrossfade>| Name | Type | Default | Description |
|---|---|---|---|
| id | string \| number | Key of the current content – changing it starts the swap | |
| children | ReactNode | Content for the current id | |
| duration | number | 420 | Length of the swap and the size morph in ms |
| blur | number | 10 | Blur in px at the outer ends of the fade |
| morph | "height" \| "both" \| "none" | "height" | Which sides glide to the new size; both makes the box as wide as its content |
| as | "div" \| "span" | "div" | Root element – span inside buttons and other inline content |
| className | string | Extra class on the box |
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
Content keeps its natural size; the box only clips during the swap, so shadows and focus rings show otherwise