نافذة حوار

Modal

حوار منبثق متاح الوصول في React مبني على Radix: أيقونة رأس، وعنوان، ووصف، وجسم، وإجراءات تذييل، وأحجام، وحصر للتركيز، وEscape للإغلاق. يرث السمة والاتجاه.

يفتح Modal نافذة حوار من مشغل: رأس وجسم وتذييل إجراءات. يرث السمة والاتجاه من الموفر.

متى تستخدمه

استخدم Modal لمهمّة قصيرة يجب إكمالها أو إلغاؤها قبل العودة: تأكيد حذف، أو إدخال رمز تحقّق، أو مراجعة ملخّص قبل الإرسال. اجعله لغرض واحد وبأدوات قليلة.

للتدفّقات الثانوية الأطول، استخدم Drawer. للوحة خفيفة مثبّتة على أداة، استخدم Popover.

أمثلة

حوار تأكيد

الخصائص

الخصائص التي يعرّفها Modal. سمات العنصر الأصلي تمرّ كما هي.

<Modal>

الخاصيةالنوعالافتراضيالوصف
childrenReactNode
openboolean
defaultOpenboolean
onOpenChange(open: boolean) => void
modalboolean

<ModalTrigger>

الخاصيةالنوعالافتراضيالوصف
asChildboolean

<ModalClose>

الخاصيةالنوعالافتراضيالوصف
asChildboolean

<ModalContent>

الخاصيةالنوعالافتراضيالوصف
size"default" | "full"
centeredboolean
showCloseButtonbooleanRender the corner X close button. Defaults to true. Set false for action-forcing dialogs where the user must pick a footer action.
closeLabelstringLocalized label for the close button. Defaults to "Close".
forceMounttrueUsed to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
onOpenAutoFocus(event: Event) => voidEvent handler called when auto-focusing on open. Can be prevented.
onCloseAutoFocus(event: Event) => voidEvent handler called when auto-focusing on close. Can be prevented.
deferPointerDownOutsidebooleanWhen true, a 'pointerdown' event outside of the layered element will wait for the interaction's click event before dispatching, allowing third-party code to stop propagation of later events and cancel dismissal.
onEscapeKeyDown(event: KeyboardEvent) => voidEvent handler called when the escape key is down. Can be prevented.
onPointerDownOutside(event: PointerDownOutsideEvent) => voidEvent handler called when the a pointerdown event happens outside of the DismissableLayer. Can be prevented.
onFocusOutside(event: FocusOutsideEvent) => voidEvent handler called when the focus moves outside of the DismissableLayer. Can be prevented.
onInteractOutside(event: PointerDownOutsideEvent | FocusOutsideEvent) => voidEvent handler called when an interaction happens outside the DismissableLayer. Specifically, when a pointerdown event happens outside or focus moves outside of it. Can be prevented.
asChildboolean

<ModalHeader>

الخاصيةالنوعالافتراضيالوصف
asChildboolean
iconreact.ReactNodeOptional featured icon shown above the title in a 40px SDGA disc.

<ModalTitle>

الخاصيةالنوعالافتراضيالوصف
asChildbooleanOverride the heading element (e.g. render an <h3> instead of the default <h2>).

<ModalDescription>

الخاصيةالنوعالافتراضيالوصف
asChildbooleanOverride the element (e.g. render a <div> for richer markup).

إمكانية الوصول

Modal حوار Radix: يعرض role="dialog" مع aria-modal، ويحصر التركيز أثناء الفتح، ويغلق بـ Escape، ويعيد التركيز إلى المشغّل عند الإغلاق. يُربط ModalTitle وModalDescription بالحوار فيُعلن اسمه وغرضه.

يستخدم زر الإغلاق closeLabel اسمًا متاحًا، وترث الطبقة الاتجاه والسمة من المزوّد.