Skip to main content
Version: v7

ion-menu

shadow

The menu component is a navigation drawer that slides in from the side of the current view. By default, it uses the start side, making it slide in from the left for LTR and right for RTL, but the side can be overridden. The menu will be displayed differently based on the mode, however the display type can be changed to any of the available menu types.

The menu element should be a sibling to the root content element. There can be any number of menus attached to the content. These can be controlled from the templates, or programmatically using the MenuController.

Basic Usage

The menu toggle component can be used to create custom button that can open or close the menu.

The type property can be used to customize how menus display in your application.

Menus are displayed on the "start" side by default. In apps that use left-to-right direction, this is the left side, and in right-to-left apps, this will be the right side. Menus can also be set to display on the "end" side, which is the opposite of "start".

If menus on both sides are needed in an app, the menu can be opened by passing the side value to the open method on MenuController. If a side is not provided, the menu on the "start" side will be opened. See the multiple menus section below for an example using MenuController.

Multiple Menus

When multiple menus exist on the same side, we need refer to them by ID instead of side. Otherwise, the wrong menu may be activated.

Theming

CSS Shadow Parts

Interfaces

While not required, this interface can be used in place of the CustomEvent interface for stronger typing with Ionic events emitted from this component.

interface MenuCustomEvent<T = any> extends CustomEvent {
detail: T;
target: HTMLIonMenuElement;
}

Properties

contentId

DescriptionThe id of the main content. When using a router this is typically ion-router-outlet. When not using a router, this is typically your main view's ion-content. This is not the id of the ion-content inside of your ion-menu.
Attributecontent-id
Typestring | undefined
Defaultundefined

disabled

Descriptiontrueの場合、メニューは無効化される。
Attributedisabled
Typeboolean
Defaultfalse

maxEdgeStart

DescriptionThe edge threshold for dragging the menu open. If a drag/swipe happens over this value, the menu is not triggered.
Attributemax-edge-start
Typenumber
Default50
DescriptionメニューのIDです。
Attributemenu-id
Typestring | undefined
Defaultundefined

side

Descriptionメニューがビューのどの側に配置されるべきか。
Attributeside
Type"end" | "start"
Default'start'

swipeGesture

Descriptiontrueの場合、スワイプによるメニュー操作が有効になる。
Attributeswipe-gesture
Typeboolean
Defaulttrue

type

DescriptionThe display type of the menu. Available options: "overlay", "reveal", "push".
Attributetype
Typestring | undefined
Defaultundefined

Events

NameDescriptionBubbles
ionDidCloseメニューが閉じられたときに発行されます。true
ionDidOpenメニューが開いているときに発行されます。true
ionWillCloseメニューが閉じられようとするときに発行されます。true
ionWillOpenメニューが開かれようとするときに発行されます。true

Methods

close

DescriptionCloses the menu. If the menu is already closed or it can't be closed, it returns false.
Signatureclose(animated?: boolean) => Promise<boolean>

isActive

DescriptionReturns true is the menu is active.

A menu is active when it can be opened or closed, meaning it's enabled and it's not part of a ion-split-pane.
SignatureisActive() => Promise<boolean>

isOpen

Descriptionメニューが開いている場合は true を返します。
SignatureisOpen() => Promise<boolean>

open

DescriptionOpens the menu. If the menu is already open or it can't be opened, it returns false.
Signatureopen(animated?: boolean) => Promise<boolean>

setOpen

DescriptionOpens or closes the button. If the operation can't be completed successfully, it returns false.
SignaturesetOpen(shouldOpen: boolean, animated?: boolean) => Promise<boolean>

toggle

DescriptionToggles the menu. If the menu is already open, it will try to close, otherwise it will try to open it. If the operation can't be completed successfully, it returns false.
Signaturetoggle(animated?: boolean) => Promise<boolean>

CSS Shadow Parts

NameDescription
backdropメニューを開いているときに、メインコンテンツの上に表示される背景です。
containerメニューの内容を格納するコンテナです。

CSS Custom Properties

NameDescription
--backgroundメニューの背景
--heightメニューの高さ
--max-heightメニューの最大の高さ
--max-widthメニューの最大幅
--min-heightメニューの高さの最小値
--min-widthメニューの最小幅
--widthメニューの幅

Slots

No slots available for this component.