naive-ui/demo/documentation/components/layout/enUS/collapse.md

75 lines
1.7 KiB
Markdown
Raw Normal View History

# Collapse Sider
Use `collapsed` prop to control status of sider.
Sider has two `collapse-mode`: `width`, `transform`. `width` will actually change width of sider, `transform` will just move sider out of layout.
Use `collapsed-width` and `width` to set sider's width.
```html
<n-switch v-model="collapsed" />
2020-01-13 23:06:58 +08:00
<n-layout>
<n-layout-header style="height: 64px;">
Cool Header
</n-layout-header>
<n-layout>
<n-layout-sider
collapse-mode="width"
:collapsed-width="120"
:width="240"
:collapsed="collapsed"
show-toggle-button
@collapse="collapsed = true"
@expand="collapsed = false"
>
Cool Sider Cool Sider Cool Sider
</n-layout-sider>
<n-layout>
<n-layout-content>
<span>Content</span>
</n-layout-content>
<n-layout-footer>
<n-h1>Footer</n-h1>
</n-layout-footer>
</n-layout>
</n-layout>
</n-layout>
<n-layout style="height: 240px; overflow: hidden;">
<n-layout-header position="absolute" style="height: 64px;">
Cool Header
</n-layout-header>
<n-layout position="absolute" style="top: 64px;">
<n-layout-sider
position="absolute"
collapse-mode="transform"
:collapsed-width="120"
:width="240"
:collapsed="collapsed"
show-toggle-button
@collapse="collapsed = true"
@expand="collapsed = false"
>
<n-h1>Sider</n-h1>
</n-layout-sider>
<n-layout
position="absolute"
>
<span>Content</span>
</n-layout>
</n-layout>
</n-layout>
```
2020-01-13 23:06:58 +08:00
```js
2020-01-15 13:41:21 +08:00
import mdContacts from 'naive-ui/lib/icons/md-contacts'
2020-01-13 23:06:58 +08:00
export default {
2020-01-13 23:06:58 +08:00
components: {
2020-01-15 13:41:21 +08:00
mdContacts
2020-01-13 23:06:58 +08:00
},
data () {
return {
2020-01-13 23:06:58 +08:00
activeMenuItemName: null,
2019-11-26 19:16:10 +08:00
collapsed: true
}
}
}
```