MeDo

منشئ النوافذ المنبثقة بالذكاء الاصطناعي.

صِف الحوار الذي تحتاجه ويُنشئ MeDo كل شيء — رأس ومحتوى قابل للتمرير وتذييل للإجراءات، إضافة إلى حصر التركيز واستعادته عند الإغلاق وقفل تمرير body ونسخة ورقة سفلية للجوّال.

نافذة منبثقة
نافذة منبثقة

الجزء الصعب في النافذة المنبثقة هو الصفحة التي تقف خلفها

تبدو النافذة المنبثقة كصندوق متوسّط بظل، ولهذا يُعاد بناؤها بشكل سيئ مراراً. الطبقة البصرية بسيطة؛ أما الجزء الصعب فيقع بالكامل خارج المكوّن. فتح الحوار يجب أن يجمّد المستند الذي تحته، وأن يلتقط تركيز لوحة المفاتيح كي لا يتسلل Tab إلى محتوى مخفي، وأن يحجب بقية الصفحة عن التقنيات المساعدة، ثم يعيد التركيز إلى العنصر ذاته الذي فتحه. إن أُهملت هذه الخطوة الأخيرة، عاد مستخدم لوحة المفاتيح بصمت إلى أعلى المستند دون أن يعرف موضعه. إنشاء الحوار مع عقد التركيز الخاص به معاً يعني أن آلة الحالات هذه صحيحة من أول عرض، لا مُرقّعة بعد جولة اختبار الجودة.

6 قالبًا

قوالب نافذة منبثقة التي يمكنك توليدها

كل قالب هو طلب حقيقي لا صورة. انسخه إلى أي محرّر ذكاء اصطناعي، أو شغّله في MeDo لتحصل على كود React و Tailwind مباشرة.

BasicHeader + Footer

Composable Dialog With Focus Management

The base every other dialog extends. The visual layer takes minutes; the focus contract is the part worth generating rather than hand-writing.

Create a modal dialog with three sizes — sm 400px, md 560px, lg 760px — centered over a black backdrop at 50 percent opacity, 16px radius, soft shadow. Compose it from Header, Body and Footer slots: the header holds a title and an icon-only close button with an aria-label, the body scrolls independently at max-height 70vh, and the footer right-aligns Cancel next to a primary action. On open, move focus to the first interactive element, trap Tab and Shift+Tab inside the dialog, and lock body scroll by compensating for the scrollbar width so the page does not shift. Set role="dialog", aria-modal="true" and aria-labelledby pointing at the title, and restore focus to the trigger on close.

جرّبه في MeDo
ConfirmationDestructive Confirm

Non-Dismissible Delete Dialog

The one dialog that must ignore Escape and backdrop clicks. A stray click outside the box should never be the gesture that deletes an account.

Create a destructive confirmation dialog: a warning icon, a heading naming the exact resource, a body stating what will be lost and whether it is recoverable, and a footer with Cancel on the left and a red Confirm on the right. Ignore both Escape and backdrop clicks so the action requires a deliberate button press. Move initial focus to Cancel rather than Confirm, so a stray Enter keypress cancels instead of destroying. Use role="alertdialog" with aria-describedby on the body text. Add an optional type-to-confirm mode requiring the resource name to be typed before Confirm enables, with the comparison case-sensitive and trimmed.

جرّبه في MeDo
FormForm Dialog

Scrolling Form With Sticky Actions

A long form in a dialog needs a body that scrolls under a fixed header and footer, plus an unsaved-changes guard. Losing typed input to a misclick is unforgivable.

Create a form dialog with a fixed header, a scrolling body and a sticky footer holding Cancel and Save. Keep the header and footer outside the scroll container so the actions stay reachable in a long form. Add a dirty-state guard: when any field has changed, intercept Escape and backdrop clicks and show a nested confirm-discard step inside the same dialog rather than opening a second overlay. On validation failure, move focus to the first invalid field and scroll it into view inside the body. Set aria-busy while saving, disable Save without removing it from the tab order, and close only after the request resolves.

جرّبه في MeDo
MobileBottom Sheet

Sheet That Slides Up on Phones

A centered card on a phone leaves the buttons floating mid-screen, away from the thumb. Same component, different layout under 640px.

Create a dialog that renders as a centered card above 640px and as a bottom sheet below it: full width, rounded top corners only, sliding up from the bottom edge with a 250ms ease-out transform. Add a drag handle at the top and support swipe-to-dismiss with a velocity threshold, falling back to the close button for keyboard and assistive technology. Cap the sheet height at 90vh with the body scrolling inside, and use dynamic viewport units so the mobile browser chrome does not clip the footer. Keep focus trapping and scroll lock identical in both layouts, and disable the slide animation under prefers-reduced-motion.

جرّبه في MeDo
PlatformNative Dialog

HTML dialog With showModal

The browser already ships focus trapping, top-layer stacking and Escape handling. Choose this and you delete most of the code the custom overlay needed.

Create a modal built on the native HTML dialog element opened with showModal(), so the browser supplies focus trapping, Escape handling and top-layer stacking with no z-index management. Style the backdrop through the ::backdrop pseudo-element. Add the parts the platform does not give you: body scroll lock on open, an entry and exit animation using allow-discrete and the transition-behavior property, and a close-on-backdrop handler that compares the click target to the dialog element rather than its children. Listen for the close event to restore focus and read returnValue, and use autofocus on the element that should receive focus first.

جرّبه في MeDo
OverlayCommand Palette

Cmd+K Search Dialog

A modal whose focus stays in the input while arrow keys drive a list elsewhere. Roving focus would break typing, so this one runs on aria-activedescendant.

Create a command palette dialog opened by Cmd+K or Ctrl+K: a search input at the top with results grouped by section below, positioned near the top of the viewport rather than vertically centered. Keep DOM focus in the input at all times and move the visual selection with aria-activedescendant so arrow keys navigate the list without stealing focus from typing. Support Enter to run the highlighted command, Escape to close with focus restored to the previously active element, and a scroll-into-view on the highlighted row. Debounce the query, render an empty state naming what was searched for, and announce the result count through a polite live region.

جرّبه في MeDo

كيف تخصّص نافذة منبثقة الخاص بك

حدّد الحوارات التي يجب ألا تُغلق بالنقر خارجها

Escape والنقر على الخلفية هما السلوك الافتراضي الصحيح للحوارات المعلوماتية، لكنهما خطر في تأكيدات الإجراءات التدميرية والنماذج متعددة الخطوات ذات المدخلات غير المحفوظة. سمِّ النسخ التي يجب أن تتجاهل الاثنين، حتى لا تحذف نقرة عابرة خارج الصندوق حساباً بالكامل.

اطلب استعادة التركيز، لا حصره فقط

معظم الموجهات تنجح في الحصر وتنسى رحلة العودة. حدّد أن التركيز يعود إلى العنصر المُشغِّل عند الإغلاق، وأن الحوار يخزّن ذلك المرجع عند الفتح، ليتابع مستخدمو لوحة المفاتيح من حيث توقفوا بالضبط.

اختر التوسيط أو الورقة السفلية لكل نقطة انكسار

الحوار المتوسّط على الهاتف يترك أزرار الإجراءات معلّقة في منتصف الشاشة، بعيداً عن الإبهام. اطلب ورقة سفلية تحت 640px يكون فيها الإجراء الرئيسي في المتناول، واحفظ التخطيط المتوسّط لنوافذ العرض الأوسع.

لا تفتح أبداً نافذة منبثقة من داخل نافذة منبثقة

الحوار الثاني فوق الأول يكسر حصر التركيز، ويضاعف الخلفية، ويترك التباساً حول الطبقة التي يغلقها Escape. اطلب بدلاً من ذلك محتوى مقسّماً إلى خطوات داخل حوار واحد، لتبقى الطبقة العلوية طبقة واحدة بمالك واحد للتركيز.

من يستخدم مكوّن نافذة منبثقة

منتج SaaS

حوار تأكيد لا يمكن إغلاقه بالنقر خارجه لإلغاء الاشتراك، مع تكرار اسم الخطة في المحتوى وزر تأكيد أحمر، إلى جانب حوار أخف قابل للإغلاق لدعوة أحد أعضاء الفريق.

متجر تجارة إلكترونية

حوار عرض سريع يحتوي صور المنتج ومحدِّد المقاس وزر الإضافة إلى السلة، يُعرض كورقة سفلية على الهواتف حتى تبقى خيارات المقاس وزر السلة في متناول الإبهام.

لوحة تحكم أو أداة إدارة

تأكيد حذف جماعي يذكر عدد السجلات بدقة ويشترط كتابة اسم المورد قبل تمكين زر التأكيد، مقروناً بحوار تحرير ينزلق نموذجه الطويل داخل رأس وتذييل ثابتين.

موقع محتوى أو وسائط

حوار عرض صور بالحجم الكامل مع التنقل بمفاتيح الأسهم وEscape للإغلاق وعودة التركيز إلى الصورة المصغّرة التي فتحته، فلا يُفقد موضع التصفح في المعرض أبداً.

أنماط نافذة منبثقة لمواقع مختلفة

المكوّن نافذة منبثقة نفسه، مُهيّأ لنوع الموقع الذي يُنشر عليه.

01 / 06

SaaS Product Dialogs

Two classes of dialog with opposite dismissal rules: invite-a-teammate should close on Escape and backdrop click, cancel-my-subscription should close on neither. Decide that per variant rather than globally, because a single dismissal policy across a product means either annoying dialogs or destroyed data.

أنماط نافذة منبثقة وتنويعاته

اختر التنويعة التي تناسب بقية الصفحة، ثم ولّدها.

01 / 06

Centered Dialog

The default above 640px: a fixed-width card centered over a dimmed backdrop. Cap the height at around 70vh with the body scrolling internally, because a dialog taller than the viewport pushes its own footer out of reach and there is no page scroll left to recover it.

نافذة منبثقة في React و Next.js و Vue و Svelte

React و Next.js و Vue 3 و SvelteKit و Astro أو HTML صِرف — المكوّن نافذة منبثقة نفسه بست طرق للإضافة.

01 / 06

React Modal

Render through a portal so the dialog escapes any ancestor with overflow hidden or a transform, both of which would clip it. Store the trigger element on open and focus it again in the cleanup, which is the step most hand-rolled modals skip.

src/components/Modal.tsx

export function Modal({ open, onClose, children }) {
  const trigger = useRef(null)

  useEffect(() => {
    if (!open) return
    trigger.current = document.activeElement
    return () => trigger.current?.focus()
  }, [open])

  if (!open) return null
  return createPortal(
    <div role="dialog" aria-modal="true">{children}</div>,
    document.body
  )
}

كيف تضيف نافذة منبثقة إلى مشروعك

أربع خطوات، من اختيار قالب نافذة منبثقة إلى إطلاقه في الإنتاج.

01~30s

Pick a Dialog Template

Scan the six templates and start from the interaction — a destructive confirm, a scrolling form, a mobile bottom sheet, or a Cmd+K palette.

02~10s

Copy the Prompt

Take the prompt into MeDo, Lovable, Bolt, v0 or Cursor. State whether this dialog may be dismissed by Escape and backdrop click before you run it, since that single decision separates a helpful overlay from one that deletes data on a misclick.

03~1min

Generate and Refine

You get React + Tailwind back with a live preview. Follow up in plain English — "make it a bottom sheet under 640px", "focus Cancel first", "build it on the native dialog element" — rather than rewiring the focus trap yourself.

04~2min

Test It With the Keyboard Only

Open it, Tab to the end and confirm focus cycles instead of escaping into the page, then close it and check focus returned to the trigger. Those two checks catch nearly every modal defect that ships.

أسئلة شائعة حول نافذة منبثقة

كيف أُنشئ مكوّن نافذة منبثقة بالذكاء الاصطناعي؟

صِف التخطيط والأحجام وقواعد الإغلاق في موجه واحد — مثلاً "حوار متوسّط بعرض 560px مع محتوى قابل للتمرير وإجراءي إلغاء وتأكيد ونسخة تدميرية تتجاهل Escape". يُنشئ MeDo المكوّن مع حصر التركيز واستعادته وقفل التمرير ودلالات الحوار مضمّنة، فتحصل على طبقة عاملة فعلاً لا مجرد div مُنسَّق.

ما هو حصر التركيز ولماذا تحتاجه النافذة المنبثقة؟

يحفظ حصر التركيز تنقّل Tab وShift+Tab بين العناصر التفاعلية داخل الحوار بدلاً من الهروب إلى الصفحة تحته. بدونه ينتقل مستخدم لوحة المفاتيح من زر التأكيد إلى روابط لا يراها، وهذا مُحيِّر ومخالف لمعايير WCAG. ويجب دائماً إقران الحصر باستعادة التركيز، بإعادته إلى العنصر المُشغِّل عند إغلاق الحوار.

هل يجب أن تُغلق النافذة المنبثقة عند النقر على الخلفية؟

في الحوارات المعلوماتية وقليلة المخاطر، نعم — النقر على الخلفية وEscape هما نمطا الإغلاق المتوقعان. أما في تأكيدات الإجراءات التدميرية والنماذج ذات المدخلات غير المحفوظة، فلا: نقرة عرضية خارج الصندوق لا يجوز أن تحذف بيانات أو تُلغي ما كُتب. اشترط الضغط الصريح على زر لكل إجراء لا يمكن التراجع عنه.

هل يمكنني استخدام عنصر <dialog> الأصلي في HTML بدل نافذة منبثقة مخصّصة؟

غالباً نعم. يمنحك عنصر <dialog> الأصلي مع showModal() حصر التركيز ومعالجة Escape والتكديس في الطبقة العلوية وعنصراً زائفاً ::backdrop مجاناً، دون إدارة z-index. لكن عليك قفل تمرير body وتحريكه بنفسك، وتحتاج المتصفحات القديمة إلى بديل احتياطي. أخبر MeDo أنك تريد العنصر الأصلي وسيبني فوقه بدلاً من إعادة تنفيذ السلوك.

كيف يجب أن تتصرّف النافذة المنبثقة على الجوّال؟

تحت 640px تقريباً، تتفوّق الورقة السفلية عادة على البطاقة المتوسّطة: تُثبِّت الإجراء الرئيسي قرب الإبهام، وتستخدم العرض الكامل لحقول النموذج، وتوافق عُرف المنصة الذي يعرفه المستخدمون سلفاً. يمكن لـ MeDo إنشاء التخطيطين في مكوّن واحد والتبديل بينهما عند نقطة الانكسار التي تحددها.

هل تحتاج النافذة المنبثقة إلى role="dialog" و aria-modal؟

نعم، إلا إذا كنت تستخدم عنصر <dialog> الأصلي الذي يوفّر الدلالات بنفسه. الطبقة المخصّصة تحتاج role="dialog" وaria-modal="true" وإما aria-labelledby يشير إلى العنوان الظاهر أو aria-label عند عدم وجود عنوان ظاهر. بدون aria-modal، تستمر قارئات الشاشة في عرض الصفحة الواقعة خلف الطبقة كمحتوى قابل للتصفح.