shadcn-impl-responsive-dialog-drawer

Build responsive shadcn modals switching between Dialog and Drawer by viewport width.

Updated May 19, 2026
One-click install
npx skills add https://github.com/Impertio-Studio/shadcn-ui-Claude-Skill-Package --skill shadcn-impl-responsive-dialog-drawer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shadcn-impl-responsive-dialog-drawer
Source: https://github.com/Impertio-Studio/shadcn-ui-Claude-Skill-Package/tree/main/skills/source/shadcn-impl/shadcn-impl-responsive-dialog-drawer
Command: npx skills add https://github.com/Impertio-Studio/shadcn-ui-Claude-Skill-Package --skill shadcn-impl-responsive-dialog-drawer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents brittle, inaccessible responsive modals by providing a production-ready recipe for rendering a single modal surface that becomes a centered Dialog on desktop and a bottom-sheet Drawer on mobile.

Core Features & Use Cases

  • SSR-safe responsive switching: Uses an SSR-safe useMediaQuery based on useSyncExternalStore to avoid hydration mismatches in Next.js.
  • Single open-state + early return: Maintains one open state for both branches and ensures only one modal mounts at a time to avoid duplicate role="dialog" nodes and focus-trap conflicts.
  • Shared content component contract: Enforces one shared content component for both surfaces so users never lose inputs or see different field sets across breakpoints.
  • Accessible labeling & correct close semantics: Ensures DialogTitle/DialogDescription and DrawerTitle/DrawerDescription are present, and uses DrawerClose asChild to avoid nested button HTML and ensure closing works reliably.
  • Responsive Combobox variant support: Extends the same Popover-on-desktop / Drawer-on-mobile pattern to mobile-safe combobox behavior.

Quick Start

Ask the AI to implement a responsive Edit Profile modal that uses a Dialog on screens at least 768px wide and a Drawer on smaller screens, with one shared form component and an SSR-safe media-query hook.

Frequently Asked Questions about shadcn-impl-responsive-dialog-drawer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make a shadcn ui modal switch between Dialog and Drawer based on screen size?

To make a shadcn ui modal responsive, use an SSR-safe media query hook to switch between a centered Dialog on desktop and a bottom-sheet Drawer on mobile. This approach maintains a single open state and ensures only one modal mounts at a time to prevent focus-trap conflicts.

Why does my responsive Next.js modal cause hydration mismatches?

Responsive Next.js modals cause hydration mismatches when media queries run on the client before the server render finishes. Using an SSR-safe useMediaQuery hook based on useSyncExternalStore prevents this by ensuring the server and client render the same initial modal state.

How do I share form content between a shadcn Dialog and Drawer without losing input state?

To share form content between a shadcn Dialog and Drawer, extract the fields into a single shared content component. Passing this shared component to both modal surfaces ensures users never lose inputs or see different field sets when switching breakpoints.

Can I use a shadcn ui Drawer for mobile combobox dropdowns?

Yes, you can use a shadcn ui Drawer for mobile combobox dropdowns by extending the responsive modal pattern. This Popover-on-desktop and Drawer-on-mobile pattern provides mobile-safe combobox behavior that adapts to the viewport width.

How do I fix nested button HTML issues in shadcn ui DrawerClose?

To fix nested button HTML issues in shadcn ui DrawerClose, use the asChild prop. This ensures the close button merges with its child element correctly, avoiding invalid HTML nesting and ensuring the closing action works reliably.

Does a responsive shadcn modal need separate open states for Dialog and Drawer?

No, a responsive shadcn modal should maintain a single open state for both the Dialog and Drawer branches. Using early-return mounting ensures only one modal surface mounts at a time, preventing duplicate role attributes and focus-trap conflicts.