I want to use the shadcn dialog in both desctop and mobile.
in desctop i place on the center of the page, but in mobile it's not.
it's not get centered and as overflow
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
This is a common issue when using modal/dialog components like shadcn/ui Dialog in React projects, especially when you want them to be perfectly centered on desktop and also look good on mobile (handling overflow, centering, and responsiveness).
Why This Happens
By default, many dialog/modal libraries use fixed widths and heights, which can cause overflow on small screens.
CSS centering techniques that work on desktop (like margin: auto or transform: translate(-50%, -50%)) can break on mobile if the dialog is too wide or tall.
How to Fix
1. Responsive Dialog Sizing
Override the dialog's content styles to use responsive widths and max-heights.
Example with shadcn/ui Dialog
Suppose you use the Dialog like this:
jsx
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog"
<Dialog>
<DialogTrigger>Open Dialog</DialogTrigger>
<DialogContent>
{/* Your content */}
</DialogContent>
</Dialog>
Add Responsive Styles
You can use Tailwind CSS (if you use shadcn/ui, you probably do) to make the dialog responsive: