Basic
import Modal from "./modal"
type WindowContentProps = {
onCloseModal?: () => void
}
function WindowContent({ onCloseModal }: WindowContentProps) {
return (
<div className="space-y-4">
<p className="text-sm text-muted-foreground">
This content is rendered inside <code className="font-mono">Modal.Window</code>.
</p>
<div className="flex flex-wrap items-center gap-3">
<button
type="button"
onClick={onCloseModal}
className="rounded-md border border-border bg-background px-3 py-2 text-sm hover:bg-muted"
>
Close
</button>
</div>
</div>
)
}
export function ModalBasicPreview() {
return (
<Modal>
<div className="flex flex-wrap items-center gap-3">
<Modal.Open opens="basic">
<button
type="button"
className="rounded-md border border-border bg-background px-3 py-2 text-sm hover:bg-muted"
>
Open modal
</button>
</Modal.Open>
</div>
<Modal.Window name="basic">
<WindowContent />
</Modal.Window>
</Modal>
)
}
Confirm
// If you're using Next.js (App Router) and this preview is interactive,
// add: "use client"
import Modal from "./modal"
type WindowContentProps = {
onCloseModal?: () => void
}
function ConfirmContent({ onCloseModal }: WindowContentProps) {
return (
<div className="space-y-4">
<p className="text-sm text-muted-foreground">Confirm variant example.</p>
<div className="flex flex-wrap items-center gap-3">
<button
type="button"
onClick={onCloseModal}
className="rounded-md border border-border bg-background px-3 py-2 text-sm hover:bg-muted"
>
Cancel
</button>
<button
type="button"
onClick={onCloseModal}
className="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground hover:opacity-90"
>
Confirm
</button>
</div>
</div>
)
}
export function ModalConfirmPreview() {
return (
<Modal>
<div className="flex flex-wrap items-center gap-3">
<Modal.Open opens="confirm">
<button
type="button"
className="rounded-md border border-border bg-background px-3 py-2 text-sm hover:bg-muted"
>
Open confirm
</button>
</Modal.Open>
</div>
<Modal.Window name="confirm">
<ConfirmContent />
</Modal.Window>
</Modal>
)
}