Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
lobehub avatar

Modal

  • 1.5k installs
  • 81.3k repo stars
  • Updated August 5, 2026
  • lobehub/lobe-chat

This is a copy of modal by lobehub - installs and ranking accrue to the original listing.

modal is a LobeChat frontend skill that implements dialogs and confirm flows with @lobehub/ui/base-ui imperative APIs for developers who migrate off antd Modal or add ModalHost-wired popups in LobeHub apps.

About

modal is a lobehub/lobe-chat skill marked user-invocable false that documents LobeHub imperative modal conventions on the base-ui stack instead of antd Modal. New code should import createModal, confirmModal, and ModalHost from @lobehub/ui/base-ui, with useModalContext inside modal content components. Body content passes via content or children, resolved as content ?? children at runtime. A global ModalHost is required because base-ui createModal renders through the host. The skill covers creating, migrating, and wiring confirm flows and popups consistently. Developers reach for modal when adding LobeChat dialogs or replacing legacy antd modals with headless base-ui primitives.

  • Enforces @lobehub/ui/base-ui primitives: createModal, confirmModal, ModalHost, and useModalContext
  • Requires mounting a dedicated Global ModalHost near the app root for imperative calls to render
  • Recommends imperative API over declarative open-state Modals to eliminate local state management
  • Defines exact file structure with features/MyFeatureModal/index.tsx exporting createXxxModal
  • Handles content slot fallback (content ?? children) and migration path from legacy antd Modal

Modal by the numbers

  • 1,528 all-time installs (skills.sh)
  • +84 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/lobehub/lobe-chat --skill modal

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1.5k
repo stars81.3k
Security audit3 / 3 scanners passed
Last updatedAugust 5, 2026
Repositorylobehub/lobe-chat

How do you implement LobeChat base-ui modals?

Consistently implement modals, dialogs, and popup flows using LobeHub's preferred imperative base-ui conventions.

Who is it for?

LobeChat frontend developers adding or migrating dialogs to @lobehub/ui/base-ui imperative APIs with ModalHost.

Skip if: Non-LobeHub React apps, antd Modal-only codebases without migration intent, or backend API modal endpoints.

When should I use this skill?

A developer creates or migrates modals, dialogs, confirm flows, ModalHost wiring, or base-ui modal APIs in LobeChat.

What you get

Imperative modals using createModal and confirmModal, global ModalHost wiring, and useModalContext inside modal content components.

  • imperative modal components
  • ModalHost setup
  • confirm dialog flows

Files

SKILL.mdMarkdownGitHub ↗

Modal Imperative API Guide

Recommended: @lobehub/ui/base-ui

New code should use the base-ui modal stack (headless primitives, not antd Modal):

  • createModal, confirmModal, ModalHost from @lobehub/ui/base-ui
  • useModalContext from @lobehub/ui/base-ui inside modal content

Body slot: pass `content` (or children; runtime uses content ?? children).

Global ModalHost (required)

Base-ui createModal renders through a separate host from the root package. The app must mount `ModalHost` from @lobehub/ui/base-ui once near the root (e.g. next to other global hosts). Without it, createModal calls will not appear.

If the project only mounts ModalHost from @lobehub/ui, add a second lazy ModalHost from @lobehub/ui/base-ui until all imperative modals are migrated.

Why imperative?

ModeCharacteristicsRecommended
Declarativeopen state + <Modal />
ImperativeCall createModal(), no local state

File structure

features/
└── MyFeatureModal/
    ├── index.tsx            # export createXxxModal
    └── MyFeatureContent.tsx # modal body

1. Content (MyFeatureContent.tsx)

'use client';

import { useModalContext } from '@lobehub/ui/base-ui';
import { useTranslation } from 'react-i18next';

export const MyFeatureContent = () => {
  const { t } = useTranslation('namespace');
  const { close } = useModalContext();

  return <div>{/* ... */}</div>;
};

2. createModal (index.tsx)

'use client';

import { createModal } from '@lobehub/ui/base-ui';
import { t } from 'i18next';

import { MyFeatureContent } from './MyFeatureContent';

export const createMyFeatureModal = () =>
  createModal({
    content: <MyFeatureContent />,
    footer: null,
    maskClosable: true,
    styles: {
      content: { overflow: 'hidden', padding: 0 },
    },
    title: t('myFeature.title', { ns: 'setting' }),
    width: 'min(80%, 800px)',
  });

3. Usage

import { createMyFeatureModal } from '@/features/MyFeatureModal';

const handleOpen = useCallback(() => {
  createMyFeatureModal();
}, []);

return <Button onClick={handleOpen}>Open</Button>;

i18n

  • Content: useTranslation in components.
  • `createModal` options: import { t } from 'i18next' where hooks are unavailable.

useModalContext

const { close, setCanDismissByClickOutside } = useModalContext();

Common options (base-ui)

ImperativeModalProps builds on BaseModalProps: title, width, maskClosable, open, onOpenChange, footer, styles / classNames (keys: backdrop, popup, header, title, close, content, …).

PropertyNotes
contentMain body (preferred name vs children)
maskClosableClick outside to dismiss
styles.*Semantic regions, not antd styles.body

Confirm

import { confirmModal } from '@lobehub/ui/base-ui';

confirmModal({
  title: '…',
  content: '…',
  okText: '…',
  cancelText: '…',
  onOk: async () => {},
});

---

Legacy: @lobehub/ui (root)

Older call sites use `createModal` from `@lobehub/ui`, which is typed as antd `Modal` props (children, allowFullscreen, getContainer, destroyOnHidden, styles.body, etc.). Prefer migrating new work to `@lobehub/ui/base-ui`.

Examples (legacy): src/features/SkillStore/index.tsx, src/features/LibraryModal/CreateNew/index.tsx.

---

Examples

  • Base-ui (preferred): follow sections above; ensure base-ui `ModalHost` is mounted.
  • Legacy: src/features/SkillStore/index.tsx, src/features/LibraryModal/CreateNew/index.tsx

Related skills

How it compares

Pick modal over generic React dialog guides when you need LobeHub-specific base-ui imperative APIs and ModalHost conventions.

FAQ

Which package does the modal skill recommend?

The modal skill recommends @lobehub/ui/base-ui with createModal, confirmModal, ModalHost, and useModalContext. New LobeChat code should avoid antd Modal in favor of this headless base-ui stack.

Why is ModalHost required for LobeChat modals?

base-ui createModal renders imperatively through a global ModalHost. The modal skill documents wiring ModalHost at the app root so programmatic dialogs and confirm flows mount correctly.

Is Modal safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Frontend Developmentfrontendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.