Dashboard Dialog
A focus-trapping modal with Escape handling that cooperates with open select lists. Class slots for overlay, backdrop and panel.
npx shadcn@latest add https://ui.develop-better-solutions.com/r/dash-dialog.jsonUsage
dash-dialog-example.tsx
"use client";
import { useState } from "react";
import { DashDialog } from "@dbs/ui";
import { DashScope } from "./_store";
export default function DashDialogExample() {
const [open, setOpen] = useState(false);
return (
<div className="w-full max-w-3xl">
<DashScope minHeight={380}>
<button
type="button"
onClick={() => setOpen(true)}
className="h-11 rounded-full bg-[var(--dash-bar)] px-6 text-sm font-medium text-[var(--dash-shell)]"
>
New appointment
</button>
<DashDialog
open={open}
onClose={() => setOpen(false)}
labelId="dash-dialog-title"
overlayClassName="fixed inset-0 z-50 flex items-center justify-center p-4"
backdropClassName="absolute inset-0 bg-black/50"
panelClassName="relative w-full max-w-md rounded-2xl border border-[var(--dash-line)] bg-[var(--dash-panel)] p-6 text-[var(--dash-ink)] shadow-2xl"
>
<h2 id="dash-dialog-title" className="text-lg font-semibold">
New appointment
</h2>
<p className="mt-2 text-sm text-[var(--dash-muted)]">
Focus stays inside the dialog. Escape closes it, and an open select list closes first.
</p>
<div className="mt-5 flex justify-end gap-2">
<button type="button" onClick={() => setOpen(false)} className="rounded-full border border-[var(--dash-line)] px-4 py-2 text-sm">
Cancel
</button>
<button type="button" onClick={() => setOpen(false)} className="rounded-full bg-[var(--dash-bar)] px-4 py-2 text-sm text-[var(--dash-shell)]">
Book
</button>
</div>
</DashDialog>
</DashScope>
</div>
);
}