Menu
Menu (메뉴)
아래로 펼쳐지는 메뉴 리스트예요. 필터 조건을 고르는 바닥글(down-drop) 스타일의 메뉴를 만들 때 쓰고, 여러 개의 MenuItem을 나란히 두어 독립적으로 열고 닫을 수 있어요.
출처: 문서
본문
소개 (Intro)
아래쪽으로 펼쳐지는 메뉴 리스트예요.
설치 (Install)
import { createApp } from 'vue'
import { Menu, MenuItem } from '@nutui/nutui'
const app = createApp()
app.use(Menu)
app.use(MenuItem)
데모 (Demos)
아래 항목들은 원문 문서의 대화형 데모로 제공돼요.
- 기본 사용법 (Basic Usage) —
demo: menu basic - 커스텀 메뉴 콘텐츠 (Custom Menu Content) —
demo: menu custom - 한 줄에 두 컬럼 (Two Cols In One Line) —
demo: menu col - 커스텀 활성 색상 (Custom Active Color) —
demo: menu color - 커스텀 아이콘 (Custom Icons) —
demo: menu icon - 펼침 방향 (Expand Directions) —
demo: menu up - 메뉴 비활성화 (Disable Menu) —
demo: menu disabled
커스텀 메뉴 콘텐츠 (Custom Menu Content)
Menu 인스턴스의 toggle 메서드로 팝업을 닫을 수 있어요.
API
Menu Props
| Attribute | Description | Type | Default |
|---|---|---|---|
| direction | Expand direction, can be set to up | string | down |
| duration | duration time, s | string | number | 0.3 |
| active-color | Active color of title and option | string | #F2270C |
| close-on-click-overlay | Whether to close when overlay is clicked | boolean | true |
| scroll-fixed | Whether to fixed when window is scrolled, fixed position can be set | boolean | string | number | false |
| title-class | Custome title class | string | - |
| lock-scroll | Whether the background is locked | boolean | true |
| overlay | overlay | boolean | true |
Menu Slots
| Name | Description |
|---|---|
| icon | Custom title icon |
MenuItem Props
| Attribute | Description | Type | Default |
|---|---|---|---|
| title | Item title | string | 当前选中项文字 |
| options | Options | Array | - |
| disabled | Whether to disable dropdown item | boolean | false |
| cols | Display how many options in one line | number | 1 |
| active-title-class | Active custome title class | string | - |
| inactive-title-class | Inactive custome title class | string | - |
MenuItem Slots
| Name | Description |
|---|---|
| icon | Custom option icon |
MenuItem Events
| Event | Description | Arguments |
|---|---|---|
| change | Emitted select option changed | Selected value |
| toggle | Toggle menu display status, true to show,false to hide, no param is negated |
show?: boolean |
| open | Emitted when opening menu | - |
| close | Emitted when closing menu | - |
Theming
CSS Variables
The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
| Name | Default Value |
|---|---|
| --nut-menu-bar-line-height | 48px |
| --nut-menu-item-font-size | var(--nut-font-size-2) |
| --nut-menu-item-text-color | var(--nut-title-color) |
| --nut-menu-item-active-text-color | var(--nut-primary-color) |
| --nut-menu-bar-border-bottom-color | #eaf0fb |
| --nut-menu-bar-opened-z-index | 2001 |
| --nut-menu-item-disabled-color | #969799 |
| --nut-menu-title-text-padding-left | 8px |
| --nut-menu-title-text-padding-right | 8px |
| --nut-menu-item-content-padding | 12px 24px |
| --nut-menu-item-content-max-height | 214px |
| --nut-menu-item-option-padding-top | 12px |
| --nut-menu-item-option-padding-bottom | 12px |
| --nut-menu-item-option-i-margin-right | 6px |
| --nut-menu-bar-box-shadow | 0 2px 12px rgba(89, 89, 89, 0.12) |
| --nut-menu-scroll-fixed-top | 0 |
| --nut-menu-scroll-fixed-z-index | 1000 |
| --nut-menu-active-item-font-weight | 500 |
더 알아보기 (Learn more)
- 원문 문서: Menu — NutUI v4 영문 문서
- NutUI 저장소: jd-opensource/nutui