JGuang

Dialog

Dialog · Chakra UI

Preview
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0

Dialog

Used to display a dialog prompt

Provide a title, an exit and suitable initial focus. Verify modal focus containment and return focus after closing; follow native portal composition for nested overlays.

Included icon notices

The source viewer includes ICON_ATTRIBUTION.md and original notices for the icon collections used by these examples. Preserve them when redistributing examples; react-icons' wrapper license does not replace individual collection terms.

  • Lucide: ISC

Installation and initialization

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0

Initialize ChakraProvider with defaultSystem and Emotion before rendering. Preserve the host React version and inspect peer compatibility. Official npm installation supplies components, not these example source files. Use the resource setup guide for locale, next-themes and framework-specific SSR; copy the selected example source separately from npm installation.

Complete native usage example

This is the actual pinned example, not a generic API mock. Copy its source closure and retain the named export. Additional imports are listed per example below.

import { Button, CloseButton, Dialog, Portal } from "@chakra-ui/react"

export const DialogBasic = () => {
  return (
    <Dialog.Root>
      <Dialog.Trigger asChild>
        <Button variant="outline" size="sm">
          Open Dialog
        </Button>
      </Dialog.Trigger>
      <Portal>
        <Dialog.Backdrop />
        <Dialog.Positioner>
          <Dialog.Content>
            <Dialog.Header>
              <Dialog.Title>Dialog Title</Dialog.Title>
            </Dialog.Header>
            <Dialog.Body>
              <p>
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do
                eiusmod tempor incididunt ut labore et dolore magna aliqua.
              </p>
            </Dialog.Body>
            <Dialog.Footer>
              <Dialog.ActionTrigger asChild>
                <Button variant="outline">Cancel</Button>
              </Dialog.ActionTrigger>
              <Button>Save</Button>
            </Dialog.Footer>
            <Dialog.CloseTrigger asChild>
              <CloseButton size="sm" />
            </Dialog.CloseTrigger>
          </Dialog.Content>
        </Dialog.Positioner>
      </Portal>
    </Dialog.Root>
  )
}

All examples and reproduction requirements

Names identify demos, not component variant props. Copy every sourceFiles entry for the selected example. The compositions alias denotes local files, not a package. Preserve relative imports or rewrite the alias to your project's actual path. React peers are inspected separately; editor examples retain the coherent pinned Tiptap extension family.

Basic

dialog-basic · Named export DialogBasic · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-basic.tsx

With Sizes

dialog-with-sizes · Named export DialogWithSizes · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-with-sizes.tsx

With Cover

dialog-with-cover · Named export DialogWithCover · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-with-cover.tsx

With Fullscreen

dialog-with-fullscreen · Named export DialogWithFullscreen · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-with-fullscreen.tsx

With Responsive Size

dialog-with-responsive-size · Named export DialogWithResponsiveSize · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-with-responsive-size.tsx

With Placement

dialog-with-placement · Named export DialogWithPlacement · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-with-placement.tsx

Controlled

dialog-controlled · Named export DialogControlled · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 prop-types@15.8.1 react-lorem-ipsum@1.4.10
  • vendor/apps/compositions/src/examples/dialog-controlled.tsx

With Multiple Triggers

dialog-with-multiple-triggers · Named export DialogWithMultipleTriggers · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-with-multiple-triggers.tsx

With Store

dialog-with-store · Named export DialogWithStore · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-with-store.tsx

With Context

dialog-with-context · Named export DialogWithContext · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-with-context.tsx

Nested

dialog-nested · Named export DialogNested · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 prop-types@15.8.1 react-lorem-ipsum@1.4.10
  • vendor/apps/compositions/src/examples/dialog-nested.tsx

Open From Popover

dialog-open-from-popover · Named export DialogOpenFromPopover · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-open-from-popover.tsx

Open From Menu

dialog-open-from-menu · Named export DialogOpenFromMenu · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
  • vendor/apps/compositions/src/examples/dialog-open-from-menu.tsx

With Initial Focus

dialog-with-initial-focus · Named export DialogWithInitialFocus · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-with-initial-focus.tsx

With Inside Scroll

dialog-with-inside-scroll · Named export DialogWithInsideScroll · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 prop-types@15.8.1 react-lorem-ipsum@1.4.10
  • vendor/apps/compositions/src/examples/dialog-with-inside-scroll.tsx

With Outside Scroll

dialog-with-outside-scroll · Named export DialogWithOutsideScroll · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 prop-types@15.8.1 react-lorem-ipsum@1.4.10
  • vendor/apps/compositions/src/examples/dialog-with-outside-scroll.tsx

With Motion Preset

dialog-with-motion-preset · Named export DialogWithMotionPreset · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-with-motion-preset.tsx

With Role

dialog-with-role · Named export DialogWithRole · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-with-role.tsx

With Close Outside

dialog-with-close-outside · Named export DialogWithCloseOutside · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-with-close-outside.tsx

Non Modal

dialog-non-modal · Named export DialogNonModal · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-non-modal.tsx

With Datalist

dialog-with-datalist · Named export DialogWithDatalist · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/dialog-with-datalist.tsx

Native API and source references

The source viewer retains original declarations, imports and inheritance. Ark UI event contracts, Chakra style props and recipe types stay in their native packages; this guide does not flatten or invent their defaults. Code comments remain original source, not translated prose.

  • npm/@chakra-ui/react@3.37.0/dist/types/components/dialog/dialog.d.ts
  • npm/@chakra-ui/react@3.37.0/dist/types/components/dialog/index.d.ts
  • npm/@chakra-ui/react@3.37.0/dist/types/components/dialog/namespace.d.ts

Scoped Vite 8 interoperability

Some examples here import react-lorem-ipsum@1.4.10. The verified Vite 8 consumer uses the included authored/native-package-interop.mjs helper in its plugins list: chakraNativePackageInterop(process.cwd()). Copy that helper into the consuming build config and adjust the import path. This unwraps the package's native CommonJS default; it does not replace the component. Apply only when this export mismatch is reproduced; other bundlers may not need it.

State and installation checks

Run strict types, the target production build and real interactions. Test labels/focus/keyboard, both themes, narrow layout, empty/loading/error states where supported and cleanup after unmount. Remote demo endpoints, uploads and downloads are constrained in the preview; configure your own services. Copying a command or reaching preview-ready does not prove installation or backend success.

Provenance and license boundaries

https://github.com/chakra-ui/chakra-ui/tree/2e7517745cff2fcde0b8012f136cf99611ff262a

These are JGuang practical bilingual notes, not a full translation of upstream MDX. Original documentation and example bytes remain in vendor. Preserve repository MIT, compositions ISC metadata and separate dependency notices. The original metadata discrepancy and any missing full notices remain explicit review items; paid Chakra Pro is excluded.