V-/Srcv0.1.0beta
// alert-dialog
A modal that forces a choice: cancel, or one confirming action.
npx shadcn add @vsrc/alert-dialogOnly the vsrc surface is documented here. Everything else passes through to Radix Alert Dialog.
// AlertDialogContent
| prop | type | default | notes |
|---|---|---|---|
| glass | "subtle" | "regular" | "heavy" | LiquidGlassOptions | false | — | Optics override for the modal pane. A preset name replaces the tuned values, an object merges over them, `false` disables refraction entirely. |
Forwards `glass` to GlassSurface — engine defaults, same held-still entrance as Dialog.
The exact file the CLI copies into your project — you own it after install.
"use client";
import * as React from "react";
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
import type { GlassPreset, LiquidGlassOptions } from "vsrc/react";
import { GlassSurface } from "@/registry/vsrc/ui/glass-surface";
import { cn } from "@/lib/utils";
const AlertDialog = AlertDialogPrimitive.Root;
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
function AlertDialogOverlay({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {
return (
<AlertDialogPrimitive.Overlay
data-slot="alert-dialog-overlay"
className={cn("animate-glass-in fixed inset-0 z-50 bg-background/70", className)}
{...props}
/>
);
}
// No close affordance in the corner: an alert dialog forces a Cancel/Action choice.
function AlertDialogContent({
className,
glass,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Content> & { glass?: LiquidGlassOptions | GlassPreset | false }) {
return (
<AlertDialogPrimitive.Portal>
<AlertDialogOverlay />
<GlassSurface asChild glass={glass}>
<AlertDialogPrimitive.Content
data-slot="alert-dialog-content"
className={cn(
"animate-glass-in fixed top-1/2 left-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2",
"flex flex-col gap-4 p-8 text-foreground outline-none",
className,
)}
{...props}
/>
</GlassSurface>
</AlertDialogPrimitive.Portal>
);
}
function AlertDialogHeader({ className, ...props }: React.ComponentProps<"div">) {
return <div data-slot="alert-dialog-header" className={cn("flex flex-col gap-1.5", className)} {...props} />;
}
function AlertDialogFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div data-slot="alert-dialog-footer" className={cn("flex justify-end gap-3 pt-2", className)} {...props} />
);
}
function AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
return (
<AlertDialogPrimitive.Title
data-slot="alert-dialog-title"
className={cn("font-display text-2xl leading-tight", className)}
{...props}
/>
);
}
function AlertDialogDescription({
className,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
return (
<AlertDialogPrimitive.Description
data-slot="alert-dialog-description"
className={cn("text-sm leading-relaxed text-muted-foreground", className)}
{...props}
/>
);
}
// Action and Cancel stay unstyled passthroughs: compose them with `asChild`
// around a Button so the glass button keeps its refraction.
function AlertDialogAction(props: React.ComponentProps<typeof AlertDialogPrimitive.Action>) {
return <AlertDialogPrimitive.Action data-slot="alert-dialog-action" {...props} />;
}
function AlertDialogCancel(props: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>) {
return <AlertDialogPrimitive.Cancel data-slot="alert-dialog-cancel" {...props} />;
}
export {
AlertDialog,
AlertDialogTrigger,
AlertDialogOverlay,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogAction,
AlertDialogCancel,
};