1e41f4b71Sopenharmony_ci# Menu 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe menu bound to a component through [bindContextMenu](./ts-universal-attributes-menu.md#bindcontextmenu8) on a page can be closed as needed. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci## ContextMenu.close 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_cistatic close() 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ciCloses the menu bound to this component through [bindContextMenu](./ts-universal-attributes-menu.md#bindcontextmenu8) on a page. 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci## Example 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci```ts 23e41f4b71Sopenharmony_ci// xxx.ets 24e41f4b71Sopenharmony_ci@Entry 25e41f4b71Sopenharmony_ci@Component 26e41f4b71Sopenharmony_cistruct Index { 27e41f4b71Sopenharmony_ci @Builder MenuBuilder() { 28e41f4b71Sopenharmony_ci Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { 29e41f4b71Sopenharmony_ci Button('Test ContextMenu1') 30e41f4b71Sopenharmony_ci Divider().strokeWidth(2).margin(5).color(Color.Black) 31e41f4b71Sopenharmony_ci Button('Test ContextMenu2') 32e41f4b71Sopenharmony_ci Divider().strokeWidth(2).margin(5).color(Color.Black) 33e41f4b71Sopenharmony_ci Button('Test ContextMenu3') 34e41f4b71Sopenharmony_ci } 35e41f4b71Sopenharmony_ci .width(200) 36e41f4b71Sopenharmony_ci .height(160) 37e41f4b71Sopenharmony_ci } 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci build() { 40e41f4b71Sopenharmony_ci Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { 41e41f4b71Sopenharmony_ci Column() { 42e41f4b71Sopenharmony_ci Text("Test ContextMenu") 43e41f4b71Sopenharmony_ci .fontSize(20) 44e41f4b71Sopenharmony_ci .width('100%') 45e41f4b71Sopenharmony_ci .height(500) 46e41f4b71Sopenharmony_ci .backgroundColor(0xAFEEEE) 47e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 48e41f4b71Sopenharmony_ci } 49e41f4b71Sopenharmony_ci .bindContextMenu(this.MenuBuilder, ResponseType.LongPress) 50e41f4b71Sopenharmony_ci .onDragStart(()=>{ 51e41f4b71Sopenharmony_ci // Close the menu when the component is dragged. 52e41f4b71Sopenharmony_ci ContextMenu.close() 53e41f4b71Sopenharmony_ci }) 54e41f4b71Sopenharmony_ci } 55e41f4b71Sopenharmony_ci .width('100%') 56e41f4b71Sopenharmony_ci .height('100%') 57e41f4b71Sopenharmony_ci } 58e41f4b71Sopenharmony_ci} 59e41f4b71Sopenharmony_ci``` 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci 62