Skip to content

Commit 2dd4937

Browse files
fix(dialog-modal): set default left/right space around container
1 parent aecb15c commit 2dd4937

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/components/ui/dialog-modal.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ import { Center, Flex } from "./flex"
1111
const dialogVariant = tv({
1212
slots: {
1313
content:
14-
"data-[state=open]:animate-contentShow w-full fixed left-1/2 top-1/2 grid -translate-x-1/2 -translate-y-1/2 gap-4 rounded-md bg-background p-8 shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] focus:outline-none z-modal",
14+
/**
15+
* `w-[calc(-2rem_+_100%)]` provides 16px x-spacing around the container
16+
* instead of using `margin` to avoid positioning side-effects.
17+
* (The container is fixed positioned)
18+
*
19+
* Credit: Chakra v2 takes this approach for modal
20+
*/
21+
"data-[state=open]:animate-contentShow w-[calc(-2rem_+_100%)] fixed left-1/2 top-1/2 grid -translate-x-1/2 -translate-y-1/2 gap-4 rounded-md bg-background p-8 shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] focus:outline-none z-modal",
1522
overlay:
1623
"data-[state=open]:animate-overlayShow fixed inset-0 bg-black/70 z-overlay",
1724
header: "relative pe-12",

0 commit comments

Comments
 (0)