modal

Create and control modals with imperative APIs in React base-ui projects.

1|Updated May 20, 2026
One-click install
npx skills add https://github.com/mDevsLabs/mAI --skill modal-mdevslabs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: modal
Source: https://github.com/mDevsLabs/mAI/tree/main/.agents/skills/modal
Command: npx skills add https://github.com/mDevsLabs/mAI --skill modal-mdevslabs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Imperative modal APIs provide a deterministic way to create and control modals, dialogs, and popups from code, ensuring consistent behavior across the app.

Core Features & Use Cases

  • Imperative creation: use createModal and confirmModal to render modals without local state.
  • Global hosting: mount a ModalHost from @lobehub/ui/base-ui once near the root to ensure modals render correctly.
  • Context-aware content: useModalContext inside modal content to access close and dismiss controls.
  • Migration path: supports migrating existing modal usage from legacy approaches to base-ui primitives.

Quick Start

Mount a ModalHost near the app root and invoke createModal to display an imperatively controlled modal.

Frequently Asked Questions about modal

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

FAQPage Schema
How do I create and control modals imperatively in a React application?

You can create and control React modals imperatively by using the createModal and confirmModal APIs, which render dialogs and popups directly from code without requiring local component state management.

What is an imperative modal API and when do I need it for frontend UI?

An imperative modal API provides a deterministic way to trigger modals, dialogs, and popups directly from code logic. You need it to ensure consistent modal behavior across your frontend application without prop drilling.

Does imperative modal creation work with Lobehub base-ui?

Yes, imperative modal creation works with Lobehub base-ui. You must mount a base-ui ModalHost near your application root, then use createModal and useModalContext to build and control modal flows.

How do I access close and dismiss controls inside modal content?

You access close and dismiss controls by calling the useModalContext hook inside your modal content components. This context-aware approach provides deterministic handling of modal dismissal behaviors.

Can I migrate existing modals to base-ui primitives without local state?

Yes, you can migrate existing modal implementations to base-ui primitives. The migration path replaces local state management with global ModalHost hosting and imperative APIs like createModal and confirmModal.

Why do my imperatively created modals fail to render in the React tree?

Imperatively created modals fail to render if the base-ui ModalHost is not mounted near the application root. Mounting the ModalHost globally ensures modals render correctly within the React DOM tree.