An accessible modal that springs in over a blurred backdrop and hands focus back on close.
Install
Add it to your project
Run this in a project set up for shadcn/ui. It writes the files and installs the npm packages.
First time: connect the Infinity UI registry
- Create a personal token on your Tokens page.
- Put it in
.env.localasINFINITYUI_TOKEN. - Add the registry to
components.json:
{
"registries": {
"@infinityui": {
"url": "https://infinityui.io/r/{name}.json",
"headers": {
"Authorization": "Bearer ${INFINITYUI_TOKEN}"
}
}
}
}Using Claude Code, Codex, Cursor, Lovable or v0? See CLI & MCP for a setup prompt.
npm packages it adds
- motion
Code
import { useState } from "react";
import { Dialog } from "@/components/ui/dialog";
export default function Demo() {
const [open, setOpen] = useState(true);
return (
<div className="flex min-h-[360px] w-full items-center justify-center p-8">
<button type="button" onClick={() => setOpen(true)} className="rounded-lg border px-4 py-2">Open dialog</button>
<Dialog open={open} onOpenChange={setOpen} title="Save changes?" description="Your edits will be kept on this device.">
<div className="mt-4 flex justify-end gap-2">
<button type="button" onClick={() => setOpen(false)} className="rounded-lg border px-4 py-2">Cancel</button>
<button type="button" onClick={() => setOpen(false)} className="rounded-lg bg-neutral-900 px-4 py-2 text-white">Save</button>
</div>
</Dialog>
</div>
);
}
































