2020-02-07 22:31:26 +08:00
# Collapsed Menu
2020-02-07 23:40:07 +08:00
Use collapsable vertical menu with layout sider. Use `collapsed` to control collapse status of menu. You must set `collapsed-width` to make it collapse in a right manner. There are still some other collapse related props you can modify: `icon-size` , `collapsed-icon-size` , `overlay-width` , `overlay-min-width` . For details see API table at the bottom of the page.
2020-02-03 00:54:47 +08:00
```html
< n-switch v-model = "collapsed" / >
< n-layout >
< n-layout-sider
collapse-mode="width"
:collapsed-width="64"
:width="240"
:collapsed="collapsed"
show-toggle-button
@collapse ="collapsed = true"
@expand ="collapsed = false"
>
< n-menu
:collapsed="collapsed"
:collapsed-width="64"
2020-02-07 22:31:26 +08:00
:collapsed-icon-size="22"
2020-02-03 00:54:47 +08:00
v-model="activeMenuItemName"
>
2020-02-07 22:31:26 +08:00
< n-menu-item title = "Hear the Wind Sing" name = "hear-the-wind-sing" >
2020-02-03 00:54:47 +08:00
< template v-slot:icon >
< n-icon >
2020-02-07 22:31:26 +08:00
< book-icon / >
2020-02-03 00:54:47 +08:00
< / n-icon >
< / template >
< / n-menu-item >
2020-02-07 22:31:26 +08:00
< n-submenu title = "Pinball, 1973" name = "pinball-1973" disabled >
2020-02-03 00:54:47 +08:00
< template v-slot:icon >
< n-icon >
2020-02-07 22:31:26 +08:00
< book-icon / >
2020-02-03 00:54:47 +08:00
< / n-icon >
< / template >
2020-02-07 22:31:26 +08:00
< n-menu-item title = "Rat" name = "rat" / >
< / n-submenu >
< n-menu-item title = "A Wild Sheep Chase" name = "a-wild-sheep-chase" disabled >
2020-02-03 00:54:47 +08:00
< template v-slot:icon >
< n-icon >
2020-02-07 22:31:26 +08:00
< book-icon / >
2020-02-03 00:54:47 +08:00
< / n-icon >
< / template >
< / n-menu-item >
2020-02-07 22:31:26 +08:00
< n-submenu title = "Dance Dance Dance" name = "dance-dance-dance" >
2020-02-03 00:54:47 +08:00
< template v-slot:icon >
< n-icon >
2020-02-07 22:31:26 +08:00
< book-icon / >
2020-02-03 00:54:47 +08:00
< / n-icon >
< / template >
2020-02-07 22:31:26 +08:00
< n-menu-item-group title = "Characters" >
< n-menu-item title = "Narrator" name = "narrator" >
2020-02-07 00:05:44 +08:00
< template v-slot:icon >
< n-icon >
2020-02-07 22:31:26 +08:00
< person-icon / >
2020-02-07 00:05:44 +08:00
< / n-icon >
< / template >
< / n-menu-item >
2020-02-07 22:31:26 +08:00
< n-menu-item title = "Sheep Man" name = "sheep-man" >
< template v-slot:icon >
< n-icon >
< person-icon / >
< / n-icon >
< / template >
< / n-menu-item >
< / n-menu-item-group >
< n-submenu title = "Beverage" name = "beverage" >
< template v-slot:icon >
< n-icon >
< wine-icon / >
< / n-icon >
< / template >
< n-menu-item title = "Whisky" name = "whisky" / >
< / n-submenu >
< n-submenu title = "Food" name = "food" >
< n-menu-item title = "Sandwich" name = "sandwich" / >
2020-02-03 00:54:47 +08:00
< / n-submenu >
2020-02-07 22:31:26 +08:00
< n-menu-item title = "The past increases. The future recedes." name = "the-past-increases-the-future-recedes" / >
2020-02-03 00:54:47 +08:00
< / n-submenu >
< / n-menu >
< / n-layout-sider >
< n-layout >
< n-layout-content >
< span > Content< / span >
< / n-layout-content >
< / n-layout >
< / n-layout >
```
```js
2020-02-07 22:31:26 +08:00
import bookIcon from 'naive-ui/lib/icons/book-outline'
import personIcon from 'naive-ui/lib/icons/person-outline'
import wineIcon from 'naive-ui/lib/icons/wine-outline'
2020-02-03 00:54:47 +08:00
export default {
components: {
2020-02-07 22:31:26 +08:00
bookIcon,
personIcon,
wineIcon
2020-02-03 00:54:47 +08:00
},
data () {
return {
activeMenuItemName: null,
collapsed: true
}
}
}
```