JGuang

Menu

Menu · Chakra UI

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

Menu

Used to create an accessible dropdown menu

Retain menu keyboard navigation, submenu and dismissal behavior. Do not treat it as an arbitrary layout container; destructive commands require clear labels and appropriate application handling.

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.

  • Heroicons: MIT
  • 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, Menu, Portal } from "@chakra-ui/react"

export const MenuBasic = () => {
  return (
    <Menu.Root>
      <Menu.Trigger asChild>
        <Button variant="outline" size="sm">
          Open
        </Button>
      </Menu.Trigger>
      <Portal>
        <Menu.Positioner>
          <Menu.Content>
            <Menu.Item value="new-txt">New Text File</Menu.Item>
            <Menu.Item value="new-file">New File...</Menu.Item>
            <Menu.Item value="new-win">New Window</Menu.Item>
            <Menu.Item value="open-file">Open File...</Menu.Item>
            <Menu.Item value="export">Export</Menu.Item>
          </Menu.Content>
        </Menu.Positioner>
      </Portal>
    </Menu.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

menu-basic · Named export MenuBasic · original upstream example

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

Controlled

menu-controlled · Named export MenuControlled · original upstream example

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

With Store

menu-with-store · Named export MenuWithStore · original upstream example

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

With Command

menu-with-command · Named export MenuWithCommand · original upstream example

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

With Context Trigger

menu-with-context-trigger · Named export MenuWithContextTrigger · original upstream example

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

With Group

menu-with-group · Named export MenuWithGroup · original upstream example

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

With Danger Item

menu-with-danger-item · Named export MenuWithDangerItem · original upstream example

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

With Submenu

menu-with-submenu · Named export MenuWithSubmenu · 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/menu-with-submenu.tsx

menu-with-links · Named export MenuWithLinks · original upstream example

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

With Radio Items

menu-with-radio-items · Named export MenuWithRadioItems · 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/menu-with-radio-items.tsx

With Checkbox Items

menu-with-checkbox-items · Named export MenuWithCheckboxItems · 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/menu-with-checkbox-items.tsx

With Icon And Command

menu-with-icon-and-command · Named export MenuWithIconAndCommand · 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/menu-with-icon-and-command.tsx

With Placement

menu-with-placement · Named export MenuWithPlacement · original upstream example

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

With Avatar

menu-with-avatar · Named export MenuWithAvatar · original upstream example

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

With Anchor Rect

menu-with-anchor-rect · Named export MenuWithAnchorRect · original upstream example

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

With Mixed Layout

menu-with-mixed-layout · Named export MenuWithMixedLayout · 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/menu-with-mixed-layout.tsx

With Overflow

menu-with-overflow · Named export MenuWithOverflow · original upstream example

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

With Hide When Detached

menu-with-hide-when-detached · Named export MenuWithHideWhenDetached · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/menu-with-hide-when-detached.tsx

Open From Dialog

menu-open-from-dialog · Named export MenuOpenFromDialog · 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/menu-open-from-dialog.tsx

With Menu Item

overlay-with-menu-item · Named export OverlayWithMenuItem · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/overlay-with-menu-item.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/menu/index.d.ts
  • npm/@chakra-ui/react@3.37.0/dist/types/components/menu/menu.d.ts
  • npm/@chakra-ui/react@3.37.0/dist/types/components/menu/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.