본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Menu (메뉴)

원문 보기 위키 갱신

Menu는 위치 지정, 선택 그룹, 여러 표시 모드를 지원하는 플로팅 컨텍스트 메뉴 컴포넌트예요. 팝오버 또는 바텀 시트 두 가지 표시 모드를 제공하며, 서브메뉴와 선택 상태까지 폭넓게 구성할 수 있어요.

출처: 문서

본문

가져오기 (Import)

import { Menu, SubMenu } from 'heroui-native';

구조 (Anatomy)

<Menu>
  <Menu.Trigger>...</Menu.Trigger>
  <Menu.Portal>
    <Menu.Overlay />
    <Menu.Content presentation="popover">
      <Menu.Close />
      <Menu.Label>...</Menu.Label>
      <Menu.Group>
        <Menu.Item>
          <Menu.ItemIndicator />
          <Menu.ItemTitle>...</Menu.ItemTitle>
          <Menu.ItemDescription>...</Menu.ItemDescription>
        </Menu.Item>
      </Menu.Group>
      <SubMenu>
        <SubMenu.Trigger textValue="...">
          <SubMenu.TriggerIndicator />
          ...
        </SubMenu.Trigger>
        <SubMenu.Content>
          <Menu.Item>...</Menu.Item>
          <Menu.Item>...</Menu.Item>
        </SubMenu.Content>
      </SubMenu>
    </Menu.Content>
  </Menu.Portal>
</Menu>
  • Menu: 열림/닫힘 상태와 위치 지정을 관리하고 자식 컴포넌트에 컨텍스트를 제공하는 메인 컨테이너.
  • Menu.Trigger: 메뉴 표시 여부를 토글하는 클릭 가능한 요소.
  • Menu.Portal: 메뉴 콘텐츠를 다른 콘텐츠 위의 포털 레이어에 렌더링해요.
  • Menu.Overlay: 외부 클릭을 잡아 메뉴를 닫는 선택적 배경 오버레이.
  • Menu.Content: 두 가지 표시 모드를 가진 메뉴 콘텐츠 컨테이너 — 위치 지정과 충돌 감지가 있는 플로팅 팝오버, 또는 바텀 시트 모달.
  • Menu.Close: 누르면 메뉴를 닫는 닫기 버튼.
  • Menu.Label: 메뉴 안의 비상호작용 섹션 제목 텍스트.
  • Menu.Group: 선택 상태(none, single, multiple)가 있는 메뉴 항목을 그룹화해요.
  • Menu.Item: 애니메이션 누름 피드백이 있는 Pressable 메뉴 항목. 단독으로 쓰거나 Group 안에서 선택용으로 사용해요.
  • Menu.ItemTitle: 메뉴 항목의 기본 라벨 텍스트.
  • Menu.ItemDescription: 메뉴 항목의 보조 설명 텍스트.
  • Menu.ItemIndicator: 메뉴 항목의 시각적 선택 표시(체크표시 또는 점).
  • SubMenu: 펼침/접힘 상태를 관리하고 자식에게 애니메이션 컨텍스트를 제공하는 루트 컨테이너.
  • SubMenu.Background: 열려 있는 동안 서브메뉴 표면을 칠하는 absolute-fill 레이어. 자동으로 렌더링되며 SubMenu의 background 프롭으로 교체할 수 있어요.
  • SubMenu.Trigger: 서브메뉴를 열고 닫는 Pressable 행. 일반 메뉴 항목처럼 스타일링돼요.
  • SubMenu.TriggerIndicator: 서브메뉴가 열리고 닫힐 때 회전하는 애니메이션 chevron 아이콘(기본: chevron-right). SubMenu.Trigger 안에 배치해요.
  • SubMenu.Content: 서브메뉴가 열리고 닫힐 때 높이를 애니메이션하는 절대 위치 컨테이너. 안에 Menu.Item 요소를 배치해요.

사용법 (Usage)

기본 사용법 (Basic Usage)

Menu 컴포넌트는 복합 파트로 플로팅 컨텍스트 메뉴를 만들어요.

<Menu>
  <Menu.Trigger>...</Menu.Trigger>
  <Menu.Portal>
    <Menu.Overlay />
    <Menu.Content presentation="popover" width={220}>
      <Menu.Item>
        <Menu.ItemTitle>View Profile</Menu.ItemTitle>
      </Menu.Item>
      <Menu.Item>
        <Menu.ItemTitle>Settings</Menu.ItemTitle>
      </Menu.Item>
    </Menu.Content>
  </Menu.Portal>
</Menu>

항목 설명과 함께 (With Item Descriptions)

제목과 함께 보조 설명 텍스트를 메뉴 항목에 추가해요.

<Menu>
  <Menu.Trigger>...</Menu.Trigger>
  <Menu.Portal>
    <Menu.Overlay />
    <Menu.Content presentation="popover" width={260}>
      <Menu.Item className="items-start">
        <View className="flex-1">
          <Menu.ItemTitle>New file</Menu.ItemTitle>
          <Menu.ItemDescription>Create a new file</Menu.ItemDescription>
        </View>
      </Menu.Item>
      <Menu.Item className="items-start">
        <View className="flex-1">
          <Menu.ItemTitle>Copy link</Menu.ItemTitle>
          <Menu.ItemDescription>Copy the file link</Menu.ItemDescription>
        </View>
      </Menu.Item>
    </Menu.Content>
  </Menu.Portal>
</Menu>

단일 선택 (Single Selection)

Menu.Group에 selectionMode="single"을 사용하면 한 번에 하나의 항목만 선택할 수 있어요.

const [theme, setTheme] = useState<Set<MenuKey>>(() => new Set(['system']));

<Menu>
  <Menu.Trigger>...</Menu.Trigger>
  <Menu.Portal>
    <Menu.Overlay />
    <Menu.Content presentation="popover" width={180}>
      <Menu.Label>Appearance</Menu.Label>
      <Menu.Group
        selectionMode="single"
        selectedKeys={theme}
        onSelectionChange={setTheme}
      >
        <Menu.Item id="light">
          <Menu.ItemIndicator />
          <Menu.ItemTitle>Light</Menu.ItemTitle>
        </Menu.Item>
        <Menu.Item id="dark">
          <Menu.ItemIndicator />
          <Menu.ItemTitle>Dark</Menu.ItemTitle>
        </Menu.Item>
        <Menu.Item id="system">
          <Menu.ItemIndicator />
          <Menu.ItemTitle>System</Menu.ItemTitle>
        </Menu.Item>
      </Menu.Group>
    </Menu.Content>
  </Menu.Portal>
</Menu>;

다중 선택 (Multiple Selection)

selectionMode="multiple"을 사용하면 여러 항목을 동시에 선택할 수 있어요.

const [textStyles, setTextStyles] = useState<Set<MenuKey>>(
  () => new Set(['bold', 'italic'])
);

<Menu>
  <Menu.Trigger>...</Menu.Trigger>
  <Menu.Portal>
    <Menu.Overlay />
    <Menu.Content presentation="popover" width={250}>
      <Menu.Label>Text Style</Menu.Label>
      <Menu.Group
        selectionMode="multiple"
        selectedKeys={textStyles}
        onSelectionChange={setTextStyles}
      >
        <Menu.Item id="bold">
          <Menu.ItemIndicator />
          <Menu.ItemTitle>Bold</Menu.ItemTitle>
        </Menu.Item>
        <Menu.Item id="italic">
          <Menu.ItemIndicator />
          <Menu.ItemTitle>Italic</Menu.ItemTitle>
        </Menu.Item>
        <Menu.Item id="underline">
          <Menu.ItemIndicator />
          <Menu.ItemTitle>Underline</Menu.ItemTitle>
        </Menu.Item>
      </Menu.Group>
    </Menu.Content>
  </Menu.Portal>
</Menu>;

서브메뉴와 함께 (With SubMenu)

Menu.Content 안에 SubMenu를 중첩하면 누를 때 추가 항목을 드러낼 수 있어요.

<Menu>
  <Menu.Trigger asChild>
    <Button variant="secondary">Editor Menu</Button>
  </Menu.Trigger>
  <Menu.Portal>
    <Menu.Overlay />
    <Menu.Content presentation="popover" width={240}>
      <Menu.Item>
        <Menu.ItemTitle>New Space</Menu.ItemTitle>
      </Menu.Item>
      <SubMenu>
        <SubMenu.Trigger textValue="Focus">
          <SubMenu.TriggerIndicator />
          <Text className="flex-1 text-base font-medium text-foreground">
            Focus
          </Text>
        </SubMenu.Trigger>
        <SubMenu.Content>
          <Menu.Item>
            <Menu.ItemTitle>Zen Mode</Menu.ItemTitle>
          </Menu.Item>
          <Menu.Item>
            <Menu.ItemTitle>Reader Mode</Menu.ItemTitle>
          </Menu.Item>
          <Menu.Item>
            <Menu.ItemTitle>Lock Tab</Menu.ItemTitle>
          </Menu.Item>
        </SubMenu.Content>
      </SubMenu>
      <Menu.Item>
        <Menu.ItemTitle>Heading 1</Menu.ItemTitle>
      </Menu.Item>
    </Menu.Content>
  </Menu.Portal>
</Menu>

위험 variant (Danger Variant)

파괴적 액션에는 메뉴 항목에 variant="danger"을 사용해요.

<Menu>
  <Menu.Trigger>...</Menu.Trigger>
  <Menu.Portal>
    <Menu.Overlay />
    <Menu.Content presentation="popover" width={220}>
      <Menu.Item>
        <Menu.ItemTitle>Edit</Menu.ItemTitle>
      </Menu.Item>
      <Menu.Item variant="danger">
        <Menu.ItemTitle>Delete</Menu.ItemTitle>
      </Menu.Item>
    </Menu.Content>
  </Menu.Portal>
</Menu>

위치 지정 (Placements)

트리거를 기준으로 메뉴가 나타나는 위치를 제어해요.

<Menu>
  <Menu.Trigger>...</Menu.Trigger>
  <Menu.Portal>
    <Menu.Overlay />
    <Menu.Content presentation="popover" placement="right" width={200}>
      <Menu.Item>
        <Menu.ItemTitle>Option A</Menu.ItemTitle>
      </Menu.Item>
      <Menu.Item>
        <Menu.ItemTitle>Option B</Menu.ItemTitle>
      </Menu.Item>
    </Menu.Content>
  </Menu.Portal>
</Menu>

바텀 시트 표시 (Bottom Sheet Presentation)

presentation="bottom-sheet"을 사용해 메뉴 콘텐츠를 바텀 시트 모달로 표시해요.

<Menu presentation="bottom-sheet">
  <Menu.Trigger>...</Menu.Trigger>
  <Menu.Portal>
    <Menu.Overlay />
    <Menu.Content presentation="bottom-sheet">
      <Menu.Item>
        <Menu.ItemTitle>Option A</Menu.ItemTitle>
      </Menu.Item>
      <Menu.Item>
        <Menu.ItemTitle>Option B</Menu.ItemTitle>
      </Menu.Item>
    </Menu.Content>
  </Menu.Portal>
</Menu>

점 표시 (Dot Indicator)

Menu.ItemIndicator에 variant="dot"을 사용해 체크표시 대신 채워진 원을 표시해요.

<Menu>
  <Menu.Trigger>...</Menu.Trigger>
  <Menu.Portal>
    <Menu.Overlay />
    <Menu.Content presentation="popover" width={180}>
      <Menu.Group
        selectionMode="single"
        selectedKeys={alignment}
        onSelectionChange={setAlignment}
      >
        <Menu.Item id="left">
          <Menu.ItemIndicator variant="dot" />
          <Menu.ItemTitle>Left</Menu.ItemTitle>
        </Menu.Item>
        <Menu.Item id="center">
          <Menu.ItemIndicator variant="dot" />
          <Menu.ItemTitle>Center</Menu.ItemTitle>
        </Menu.Item>
        <Menu.Item id="right">
          <Menu.ItemIndicator variant="dot" />
          <Menu.ItemTitle>Right</Menu.ItemTitle>
        </Menu.Item>
      </Menu.Group>
    </Menu.Content>
  </Menu.Portal>
</Menu>

예제 (Example)

import type { MenuKey } from 'heroui-native';
import { Button, Menu, Separator } from 'heroui-native';
import { useState } from 'react';
import { Text, View } from 'react-native';

export default function MenuExample() {
  const [textStyles, setTextStyles] = useState<Set<MenuKey>>(
    () => new Set(['bold', 'italic'])
  );
  const [alignment, setAlignment] = useState<Set<MenuKey>>(
    () => new Set(['left'])
  );

  return (
    <Menu>
      <Menu.Trigger asChild>
        <Button variant="secondary">Styles</Button>
      </Menu.Trigger>
      <Menu.Portal>
        <Menu.Overlay />
        <Menu.Content presentation="popover" width={250}>
          <Menu.Label className="mb-1">Text Style</Menu.Label>
          <Menu.Group
            selectionMode="multiple"
            selectedKeys={textStyles}
            onSelectionChange={setTextStyles}
          >
            <Menu.Item id="bold">
              <Menu.ItemIndicator />
              <Menu.ItemTitle>Bold</Menu.ItemTitle>
              <Text className="text-sm text-muted">⌘ B</Text>
            </Menu.Item>
            <Menu.Item id="italic">
              <Menu.ItemIndicator />
              <Menu.ItemTitle>Italic</Menu.ItemTitle>
              <Text className="text-sm text-muted">⌘ I</Text>
            </Menu.Item>
            <Menu.Item id="underline">
              <Menu.ItemIndicator />
              <Menu.ItemTitle>Underline</Menu.ItemTitle>
              <Text className="text-sm text-muted">⌘ U</Text>
            </Menu.Item>
          </Menu.Group>
          <Separator className="mx-2 my-2 opacity-75" />
          <Menu.Label className="mb-1">Text Alignment</Menu.Label>
          <Menu.Group
            selectionMode="single"
            selectedKeys={alignment}
            onSelectionChange={setAlignment}
          >
            <Menu.Item id="left">
              <Menu.ItemIndicator variant="dot" />
              <Menu.ItemTitle>Left</Menu.ItemTitle>
            </Menu.Item>
            <Menu.Item id="center">
              <Menu.ItemIndicator variant="dot" />
              <Menu.ItemTitle>Center</Menu.ItemTitle>
            </Menu.Item>
            <Menu.Item id="right">
              <Menu.ItemIndicator variant="dot" />
              <Menu.ItemTitle>Right</Menu.ItemTitle>
            </Menu.Item>
          </Menu.Group>
        </Menu.Content>
      </Menu.Portal>
    </Menu>
  );
}

더 많은 예제는 GitHub 저장소에서 찾을 수 있어요.

API 참고 (API Reference)

prop type default description
children React.ReactNode - The content of the menu
presentation 'popover' | 'bottom-sheet' 'popover' Presentation mode for the menu content
isOpen boolean - Controlled open state of the menu
isDefaultOpen boolean - Open state when initially rendered (uncontrolled)
isDisabled boolean - Whether the menu is disabled
animation MenuRootAnimation - Animation configuration for menu root
onOpenChange (open: boolean) => void - Callback fired when the menu open state changes
...ViewProps ViewProps - All standard React Native View props are supported

메뉴 루트 컴포넌트의 애니메이션 설정이에요. 값은 다음과 같아요:

  • "disable-all": 자식을 포함한 모든 애니메이션 비활성화
  • true 또는 undefined: 기본 애니메이션 사용
prop type default description
children React.ReactNode - The trigger element content
className string - Additional CSS class for the trigger
isDisabled boolean false Whether the trigger is disabled
asChild boolean - Render as child element using Slot pattern
...PressableProps PressableProps - All standard React Native Pressable props are supported
prop type default description
children React.ReactNode - The portal content
className string - Additional CSS class for the portal container
disableFullWindowOverlay boolean false Use a regular View instead of FullWindowOverlay on iOS
unstable_accessibilityContainerViewIsModal boolean false Controls whether VoiceOver treats the overlay window as a modal container. When true, VoiceOver is restricted to elements inside the overlay. iOS only. Unstable: may change with react-native-screens updates
hostName string - Optional name of the host element for the portal
forceMount boolean - Force mount the portal regardless of open state
prop type default description
className string - Additional CSS class for the overlay
closeOnPress boolean true Whether to close the menu when the overlay is pressed
animation MenuOverlayAnimation - Animation configuration for overlay
isAnimatedStyleActive boolean true Whether animated styles (react-native-reanimated) are active
forceMount boolean - Force mount the overlay regardless of open state
...PressableProps PressableProps - All standard React Native Pressable props are supported

메뉴 오버레이 컴포넌트의 애니메이션 설정이에요. 값은 다음과 같아요:

  • false 또는 "disabled": 모든 애니메이션 비활성화
  • true 또는 undefined: 기본 애니메이션 사용
  • object: 커스텀 애니메이션 설정
prop type default description
state 'disabled' | boolean - Disable animations while customizing properties
opacity.entering.value EntryOrExitLayoutType FadeIn.duration(200) Custom entering animation for overlay
opacity.exiting.value EntryOrExitLayoutType FadeOut.duration(150) Custom exiting animation for overlay

presentation="popover"일 때의 프롭이에요.

prop type default description
children React.ReactNode - The menu content
presentation 'popover' - Presentation mode (must match Menu root)
placement 'top' | 'bottom' | 'left' | 'right' 'bottom' Where the menu appears relative to the trigger
align 'start' | 'center' | 'end' 'center' Alignment of the menu relative to the trigger
avoidCollisions boolean true Whether to reposition to avoid screen edges
offset number 9 Distance from the trigger element in pixels
alignOffset number 0 Offset along the alignment axis in pixels
width 'content-fit' | 'trigger' | 'full' | number 'content-fit' Content width sizing strategy
className string - Additional CSS class for the content container
animation MenuContentAnimation - Animation configuration for content
...ViewProps ViewProps - All standard React Native View props are supported

메뉴 팝오버 콘텐츠 컴포넌트의 애니메이션 설정이에요. 값은 다음과 같아요:

  • false 또는 "disabled": 모든 애니메이션 비활성화
  • true 또는 undefined: 기본 애니메이션 사용
  • object: 커스텀 애니메이션 설정
prop type default description
state 'disabled' | boolean - Disable animations while customizing properties
entering.value EntryOrExitLayoutType Scale + fade entering animation Custom entering animation for content
exiting.value EntryOrExitLayoutType Scale + fade exiting animation Custom exiting animation for content

presentation="bottom-sheet"일 때의 프롭이에요. @gorhom/bottom-sheet의 BottomSheet 프롭을 확장해요.

prop type default description
children React.ReactNode - The bottom sheet content
presentation 'bottom-sheet' - Presentation mode (must match Menu root)
className string - Additional CSS class for the bottom sheet
backgroundClassName string - Additional CSS class for the background
handleIndicatorClassName string - Additional CSS class for the handle indicator
contentContainerClassName string - Additional CSS class for the content container
contentContainerProps Omit<BottomSheetViewProps, 'children'> - Props for the content container
animation AnimationDisabled - Set to false or "disabled" to disable animations
...BottomSheetProps Partial<BottomSheetProps> - All @gorhom/bottom-sheet props are supported

CloseButtonProps를 확장하며, 누르면 메뉴를 자동으로 닫아요.

prop type default description
iconProps CloseButtonIconProps - Props for customizing the close icon
...ButtonProps ButtonRootProps - All Button root props are supported
prop type default description
children React.ReactNode - The group content (Menu.Item elements)
selectionMode 'none' | 'single' | 'multiple' 'none' The type of selection allowed in the group
selectedKeys Iterable<MenuKey> - Currently selected keys (controlled)
defaultSelectedKeys Iterable<MenuKey> - Initially selected keys (uncontrolled)
isDisabled boolean false Whether the entire group is disabled
disabledKeys Iterable<MenuKey> - Keys of items that should be disabled
shouldCloseOnSelect boolean - Whether selecting an item should close the menu
className string - Additional CSS class for the group container
onSelectionChange (keys: Set<MenuKey>) => void - Callback fired when the selection changes
...ViewProps ViewProps - All standard React Native View props are supported
prop type default description
children React.ReactNode - The label text content
className string - Additional CSS class for the label
...TextProps TextProps - All standard React Native Text props are supported
prop type default description
children React.ReactNode | ((props: MenuItemRenderProps) => ReactNode) - Child elements or a render function
id MenuKey - Unique identifier, required when inside a Menu.Group
variant 'default' | 'danger' 'default' Visual variant of the menu item
isDisabled boolean false Whether the item is disabled
isSelected boolean - Controlled selected state for standalone items
shouldCloseOnSelect boolean true Whether pressing this item should close the menu
className string - Additional CSS class for the item
animation MenuItemAnimation - Animation configuration for press feedback
isAnimatedStyleActive boolean true Whether animated styles (react-native-reanimated) are active
onSelectedChange (selected: boolean) => void - Callback when standalone item's selected state changes
...PressableProps PressableProps - All standard React Native Pressable props are supported

children이 함수일 때 렌더 함수에 전달되는 프롭이에요.

prop type description
isSelected boolean Whether this item is currently selected
isDisabled boolean Whether the item is disabled
isPressed SharedValue<boolean> Whether the item is currently pressed
variant 'default' | 'danger' Visual variant of the item

메뉴 항목 누름 피드백의 애니메이션 설정이에요. 값은 다음과 같아요:

  • false 또는 "disabled": 모든 항목 애니메이션 비활성화
  • true 또는 undefined: 기본 애니메이션 사용
  • object: 커스텀 애니메이션 설정
prop type default description
scale.value number 0.98 Scale value when pressed
scale.timingConfig WithTimingConfig { duration: 150 } Spring animation configuration for scale
backgroundColor.value string useThemeColor('default') Background color shown while pressed
backgroundColor.timingConfig WithTimingConfig { duration: 150 } Animation timing for background color
prop type default description
children React.ReactNode - The title text content
className string - Additional CSS class for the item title
...TextProps TextProps - All standard React Native Text props are supported
prop type default description
children React.ReactNode - The description text content
className string - Additional CSS class for the item description
...TextProps TextProps - All standard React Native Text props are supported
prop type default description
children React.ReactNode - Custom indicator content, defaults to checkmark or dot
variant 'checkmark' | 'dot' 'checkmark' Visual variant of the indicator
iconProps MenuItemIndicatorIconProps - Icon configuration (checkmark variant)
forceMount boolean true Force mount the indicator regardless of selected state
className string - Additional CSS class for the item indicator
...ViewProps ViewProps - All standard React Native View props are supported
prop type default description
size number 16 Size of the indicator icon (8 for dot variant)
color string muted Color of the indicator icon
prop type default description
children React.ReactNode - The sub-menu content (trigger, content, and other items)
isOpen boolean - Controlled open state of the sub-menu
isDefaultOpen boolean - Open state when initially rendered (uncontrolled)
isDisabled boolean false Whether the sub-menu is disabled
className string - Additional CSS class for the root container
background React.ReactNode - Background layer behind the open sub-menu surface
animation SubMenuRootAnimation - Animation configuration for the sub-menu
onOpenChange (open: boolean) => void - Callback fired when the sub-menu open state changes
...ViewProps ViewProps - All standard React Native View props are supported

SubMenu 루트 컴포넌트의 애니메이션 설정이에요. 값은 다음과 같아요:

  • "disable-all": 자식을 포함한 모든 애니메이션 비활성화
  • false 또는 "disabled": 루트 애니메이션만 비활성화
  • true 또는 undefined: 기본 애니메이션 사용
  • object: 커스텀 애니메이션 설정
prop type default description
state 'disabled' | boolean - Disable animations while customizing properties
rootContent.marginHorizontal number -16 Margin horizontal when sub-menu is open
rootContent.marginVertical number -16 Margin vertical when sub-menu is open
rootContent.paddingHorizontal number 6 Padding horizontal when sub-menu is open
rootContent.paddingTop number 12 Padding top when sub-menu is open
rootContent.springConfig WithSpringConfig { damping: 100, stiffness: 950, mass: 3 } Spring configuration for expand/collapse
background.exiting EntryOrExitLayoutType FadeOut.duration(200) Exit animation for the background layer

열려 있는 서브메뉴 표면 뒤에 렌더링되는 absolute-fill 레이어예요. 서브메뉴 표면 코트(--color-overlay)를 칠하며, 자식이 없을 때는 활성 라이브러리 테마가 선택한 레이어를 칠해요 — glass 테마에서는 GlassView 블러, 기본 테마에서는 아무것도 없어요.

표면은 서브메뉴가 열려 있는 동안에만 마운트되므로(닫힐 때 페이드아웃) 접힌 트리거 행이 그 위에 놓인 메뉴 표면을 유지해요. 반투명한 --color-overlay가 있는 테마에서 영구 코트가 트리거 행을 두 번 물들여 형제 Menu.Item들과 다르게 보이게 할 수 있기 때문에 중요한 부분이에요.

SubMenu의 background 프롭으로 교체할 수 있어요 — 커스텀 노드가 마운트와 퇴장 전환까지 담당하므로, absolute-fill, 표면 코트, 클리핑을 유지하려면 콘텐츠를 SubMenu.Background로 감싸면 돼요:

<SubMenu
  background={
    <SubMenu.Background>
      <LinearGradient
        colors={['#ffffff22', '#ffffff05']}
        style={StyleSheet.absoluteFill}
      />
    </SubMenu.Background>
  }
>
  ...
</SubMenu>

background={null}을 전달하면 레이어가 완전히 제거되어 열린 서브메뉴가 메뉴 콘텐츠 위에서 투명하게 남아요.

prop type default description
children React.ReactNode - Custom content replacing the theme default layer
className string - Additional CSS class for the background container
...ViewProps ViewProps - All standard React Native View props are supported
prop type default description
children React.ReactNode - The trigger content (title, icons, indicator, etc.)
textValue string - Accessible text value announced by screen readers
className string - Additional CSS class for the trigger
isDisabled boolean false Whether the trigger is disabled
asChild boolean - Render as child element using Slot pattern
...PressableProps PressableProps - All standard React Native Pressable props are supported

서브메뉴가 열리고 닫힐 때 회전하는 애니메이션 표시 아이콘이에요. 기본값은 chevron-right 아이콘이에요.

prop type default description
children React.ReactNode - Custom indicator content (replaces default chevron)
className string - Additional CSS class for the indicator
iconProps SubMenuTriggerIndicatorIconProps - Icon configuration for the default chevron
animation SubMenuTriggerIndicatorAnimation - Animation configuration for indicator rotation
isAnimatedStyleActive boolean true Whether animated styles (react-native-reanimated) are active
...ViewProps ViewProps - All standard React Native View props are supported
prop type default description
size number 16 Size of the indicator icon
color string muted Color of the indicator icon

트리거 표시 회전의 애니메이션 설정이에요. 값은 다음과 같아요:

  • false 또는 "disabled": 모든 애니메이션 비활성화
  • true 또는 undefined: 기본 애니메이션 사용
  • object: 커스텀 애니메이션 설정
prop type default description
state 'disabled' | boolean - Disable animations while customizing properties
rotation.value [number, number] [0, 90] Rotation values [collapsed, expanded] in degrees
rotation.springConfig WithSpringConfig { damping: 140, stiffness: 1000, mass: 4 } Spring configuration for rotation
prop type default description
children React.ReactNode - The submenu items (Menu.Item, Menu.Group, etc.)
className string - Additional CSS class for the content container
...PressableProps PressableProps - All standard React Native Pressable props are supported

훅 (Hooks)

useMenu

메뉴 루트 컨텍스트에 접근하는 훅이에요. Menu 컴포넌트 안에서 사용해야 해요.

import { useMenu } from 'heroui-native';

const { isOpen, onOpenChange, presentation, isDisabled } = useMenu();

반환값 (Returns)

property type description
isOpen boolean Whether the menu is currently open
onOpenChange (open: boolean) => void Callback to change the open state
presentation 'popover' | 'bottom-sheet' Current presentation mode
isDisabled boolean | undefined Whether the menu is disabled
nativeID string Unique identifier for the menu instance

useMenuItem

메뉴 항목 컨텍스트에 접근하는 훅이에요. Menu.Item 컴포넌트 안에서 사용해야 해요.

import { useMenuItem } from 'heroui-native';

const { id, isSelected, isDisabled, variant } = useMenuItem();

반환값 (Returns)

property type description
id MenuKey | undefined Item identifier
isSelected boolean Whether the item is currently selected
isDisabled boolean Whether the item is disabled
variant 'default' | 'danger' Visual variant of the item

useMenuAnimation

메뉴 애니메이션 컨텍스트에 접근하는 훅이에요. Menu 컴포넌트 안에서 사용해야 해요.

import { useMenuAnimation } from 'heroui-native';

const { progress, isDragging } = useMenuAnimation();

반환값 (Returns)

property type description
progress SharedValue<number> Animation progress shared value (0=idle, 1=open, 2=close)
isDragging SharedValue<boolean> Whether the bottom sheet is currently being dragged

useSubMenu

서브메뉴 컨텍스트에 접근하는 훅이에요. SubMenu 컴포넌트 안에서 사용해야 해요.

import { useSubMenu } from 'heroui-native';

const { isOpen, onOpenChange, isDisabled } = useSubMenu();

반환값 (Returns)

property type description
isOpen boolean Whether the sub-menu is currently open
onOpenChange (open: boolean) => void Callback to change the open state
isDisabled boolean Whether the sub-menu is disabled
nativeID string Unique identifier for the sub-menu instance

특별 참고 (Special Notes)

요소 검사기 (Element Inspector, iOS)

Menu는 iOS에서 FullWindowOverlay를 사용해요. 개발 중 React Native 요소 검사기를 활성화하려면 Menu.Portal에 disableFullWindowOverlay={true}를 설정하세요. 단점: 비활성화하면 메뉴가 네이티브 모달 위에 표시되지 않아요.

네이티브 모달 (Native Modal, iOS)

Menu가 네이티브 모달(presentation: 'modal' | 'formSheet' | 'pageSheet')로 표시된 화면 안에서 열리면 메뉴 콘텐츠가 위로 밀려 렌더링될 수 있어요. 새 아키텍처(Fabric)에서 react-native-screens는 RNSModalScreen을 Fabric 루트로 표시하므로, 트리거의 위치는 모달의 원점 기준으로 보고되는 반면 FullWindowOverlay(메뉴가 마운트되는 곳)는 iOS 애플리케이션 창에 고정돼요. offset에 safeAreaInsets.top을 더해 보정하세요:

import { useSafeAreaInsets } from 'react-native-safe-area-context';

const insets = useSafeAreaInsets();

<Menu.Content presentation="popover" offset={insets.top}>
  ...
</Menu.Content>;

더 알아보기 (Learn more)

  • Button, Separator와 함께 사용하는 컨텍스트 메뉴 패턴을 확인해 보세요.
  • 공식 HeroUI Native Menu 문서에서 최신 정보를 확인할 수 있어요.