Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(ui): improve dialog overlays and command menu motion (#14129)

Nikita Kabardin267dd829d1f7
diff --git a/web/src/components/ui/alert-dialog.tsx b/web/src/components/ui/alert-dialog.tsx
index 4600e2225a..3a61ee5184 100644
--- a/web/src/components/ui/alert-dialog.tsx
+++ b/web/src/components/ui/alert-dialog.tsx
@@ -5,6 +5,7 @@ import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
import { cn } from "@/src/utils/tailwind";
import { buttonVariants } from "@/src/components/ui/button";
+import motionStyles from "./dialog-motion.module.css";
const AlertDialog = AlertDialogPrimitive.Root;
@@ -18,7 +19,8 @@ const AlertDialogOverlay = React.forwardRef<
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Overlay
className={cn(
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80",
+ motionStyles.overlay,
+ "fixed inset-0 z-50 bg-black/50 dark:bg-black/65",
className,
)}
{...props}
@@ -36,7 +38,8 @@ const AlertDialogContent = React.forwardRef<
<AlertDialogPrimitive.Content
ref={ref}
className={cn(
- "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg",
+ motionStyles.content,
+ "bg-background fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg sm:rounded-lg",
className,
)}
{...props}
diff --git a/web/src/components/ui/command.tsx b/web/src/components/ui/command.tsx
index 6623a269c8..539df913ad 100644
--- a/web/src/components/ui/command.tsx
+++ b/web/src/components/ui/command.tsx
@@ -13,6 +13,8 @@ import {
DialogHeader,
} from "@/src/components/ui/dialog";
+const commandDialogSurfaceClass = "bg-background dark:bg-[rgb(15_23_42)]";
+
const Command = React.forwardRef<
React.ComponentRef<typeof CommandPrimitive>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
@@ -38,8 +40,12 @@ const CommandDialog = ({
return (
<Dialog {...props}>
<DialogContent
- className="overflow-hidden p-0 shadow-lg"
+ className={cn(
+ commandDialogSurfaceClass,
+ "top-[calc(var(--banner-offset)+clamp(4rem,14dvh,8rem))] translate-y-0 overflow-hidden border p-0 shadow-2xl dark:border-slate-700/70 dark:shadow-[0_32px_96px_-28px_rgb(0_0_0/0.95),0_16px_40px_-24px_rgb(0_0_0/0.9),0_0_0_1px_rgb(148_163_184/0.1)]",
+ )}
closeOnInteractionOutside
+ overlayMode="invisible"
>
<DialogHeader className="sr-only p-0">
<DialogTitle>Search</DialogTitle>
@@ -47,7 +53,10 @@ const CommandDialog = ({
<DialogBody className="p-0">
<Command
filter={filter}
- className="**:[[cmdk-group-heading]]:text-muted-foreground pb-1 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group]]:px-2 **:[[cmdk-input]]:h-12"
+ className={cn(
+ commandDialogSurfaceClass,
+ "**:[[cmdk-group-heading]]:text-muted-foreground pb-1 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group]]:px-2 **:[[cmdk-input]]:h-12",
+ )}
>
{children}
</Command>
diff --git a/web/src/components/ui/dialog-motion.module.css b/web/src/components/ui/dialog-motion.module.css
new file mode 100644
index 0000000000..17ca0c9799
--- /dev/null
+++ b/web/src/components/ui/dialog-motion.module.css
@@ -0,0 +1,67 @@
+.content {
+ transform-origin: center center;
+}
+
+.content[data-state="open"] {
+ animation: dialogContentIn 800ms cubic-bezier(0.16, 1, 0.3, 1) both;
+}
+
+.content[data-state="closed"] {
+ animation: dialogContentOut 180ms cubic-bezier(0.4, 0, 1, 1) both;
+}
+
+.overlay[data-state="open"] {
+ animation: dialogOverlayIn 200ms ease-out both;
+}
+
+.overlay[data-state="closed"] {
+ animation: dialogOverlayOut 150ms ease-in both;
+}
+
+@keyframes dialogContentIn {
+ 0% {
+ opacity: 0;
+ scale: 0.95;
+ }
+
+ 50% {
+ opacity: 1;
+ }
+
+ 100% {
+ opacity: 1;
+ scale: 1;
+ }
+}
+
+@keyframes dialogContentOut {
+ from {
+ opacity: 1;
+ scale: 1;
+ }
+
+ to {
+ opacity: 0;
+ scale: 0.95;
+ }
+}
+
+@keyframes dialogOverlayIn {
+ from {
+ opacity: 0;
+ }
+
+ to {
+ opacity: 1;
+ }
+}
+
+@keyframes dialogOverlayOut {
+ from {
+ opacity: 1;
+ }
+
+ to {
+ opacity: 0;
+ }
+}
diff --git a/web/src/components/ui/dialog.tsx b/web/src/components/ui/dialog.tsx
index 207245be51..585277b6ee 100644
--- a/web/src/components/ui/dialog.tsx
+++ b/web/src/components/ui/dialog.tsx
@@ -6,6 +6,7 @@ import { X } from "lucide-react";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/src/utils/tailwind";
+import motionStyles from "./dialog-motion.module.css";
const Dialog = DialogPrimitive.Root;
@@ -15,14 +16,26 @@ const DialogPortal = DialogPrimitive.Portal;
const DialogClose = DialogPrimitive.Close;
+type DialogOverlayMode = "subtle" | "invisible" | "blocking";
+
+const dialogOverlayClasses: Record<DialogOverlayMode, string> = {
+ invisible: "bg-transparent",
+ subtle: "bg-black/25 dark:bg-black/45",
+ blocking: "bg-black/50 dark:bg-black/65",
+};
+
const DialogOverlay = React.forwardRef<
React.ComponentRef<typeof DialogPrimitive.Overlay>,
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
->(({ className, ...props }, ref) => (
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> & {
+ overlayMode?: DialogOverlayMode;
+ }
+>(({ className, overlayMode = "subtle", ...props }, ref) => (
<DialogPrimitive.Overlay
ref={ref}
className={cn(
- "bg-foreground/40 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50",
+ motionStyles.overlay,
+ "fixed inset-0 z-50",
+ dialogOverlayClasses[overlayMode],
className,
)}
{...props}
@@ -31,7 +44,7 @@ const DialogOverlay = React.forwardRef<
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
const dialogContentVariants = cva(
- "fixed left-[50%] top-[50%] overflow-hidden z-50 flex w-full flex-col translate-x-[-50%] translate-y-[-50%] bg-background shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
+ "fixed left-[50%] top-[50%] overflow-hidden z-50 flex w-full translate-x-[-50%] translate-y-[-50%] flex-col bg-background shadow-lg sm:rounded-lg",
{
variants: {
size: {
@@ -52,6 +65,7 @@ const DialogContent = React.forwardRef<
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
closeOnInteractionOutside?: boolean;
confirmCloseOnEscape?: string;
+ overlayMode?: DialogOverlayMode;
stopPropagationOnEnterSpace?: boolean;
} & VariantProps<typeof dialogContentVariants>
>(
@@ -61,6 +75,7 @@ const DialogContent = React.forwardRef<
children,
closeOnInteractionOutside = false,
confirmCloseOnEscape,
+ overlayMode = "subtle",
stopPropagationOnEnterSpace = true,
onEscapeKeyDown,
size,
@@ -91,10 +106,13 @@ const DialogContent = React.forwardRef<
return (
<DialogPortal>
- <DialogOverlay />
+ <DialogOverlay overlayMode={overlayMode} />
<DialogPrimitive.Content
ref={ref}
- className={cn(dialogContentVariants({ size, className }))}
+ className={cn(
+ motionStyles.content,
+ dialogContentVariants({ size, className }),
+ )}
aria-describedby={undefined}
onKeyDown={handleKeyDown}
onEscapeKeyDown={handleEscapeKeyDown}