VEUI

VEUI on GitHub
Play!中文

Sidebar

Examples

Collapse mode

Use the collapse-mode prop to specify the collapse mode, which can be slim (partially collapsed) or hidden (completely collapsed).

/demo/sidebar/collapse-mode.vue
Edit this demo on GitHubEdit
<template>
<veui-layout>
  <veui-header class="header">
    Header
  </veui-header>
  <veui-layout>
    <veui-sidebar
      collapsible
      :collapse-mode="mode"
    >
      <div class="center full">
        Sidebar
      </div>
    </veui-sidebar>
    <veui-layout>
      <veui-content class="content">
        <veui-radio-button-group
          v-model="mode"
          class="group"
          :items="modes"
        />
      </veui-content>
      <veui-footer
        class="footer"
        style="background: #ccc;"
      >
        Footer(背景仅为演示)
      </veui-footer>
    </veui-layout>
  </veui-layout>
</veui-layout>
</template>

<script>
import { Layout, Header, Footer, Sidebar, Content, RadioButtonGroup } from 'veui'

export default {
  components: {
    'veui-layout': Layout,
    'veui-header': Header,
    'veui-footer': Footer,
    'veui-sidebar': Sidebar,
    'veui-content': Content,
    'veui-radio-button-group': RadioButtonGroup
  },
  data () {
    return {
      mode: 'slim',
      modes: [
        { label: 'slim', value: 'slim' },
        { label: 'hidden', value: 'hidden' }
      ]
    }
  }
}
</script>

<style lang="less" scoped>
.center,
.header,
.footer,
.content {
  display: flex;
  align-items: center;
  justify-content: center;
}

.group {
  margin-bottom: 12px;
}

.full {
  height: 100%;
}
</style>

Toggle button

Use the collapsible prop to show or hide the expand/collapse button of the sidebar.

/demo/sidebar/collapsible.vue
Edit this demo on GitHubEdit
<template>
<veui-layout>
  <veui-header class="heaer">
    Header
  </veui-header>
  <veui-layout>
    <veui-sidebar :collapsible="collapsible">
      <div class="center full">
        Sidebar
      </div>
    </veui-sidebar>
    <veui-layout>
      <veui-content class="content">
        <veui-switch
          v-model="collapsible"
        >
          Collapsible
        </veui-switch>
      </veui-content>
      <veui-footer
        class="footer"
        style="background: #ccc;"
      >
        Footer(背景仅为演示
      </veui-footer>
    </veui-layout>
  </veui-layout>
</veui-layout>
</template>

<script>
import { Layout, Header, Footer, Sidebar, Content, Switch } from 'veui'

export default {
  components: {
    'veui-layout': Layout,
    'veui-header': Header,
    'veui-footer': Footer,
    'veui-sidebar': Sidebar,
    'veui-content': Content,
    'veui-switch': Switch
  },
  data () {
    return {
      collapsible: true
    }
  }
}
</script>

<style lang="less" scoped>
.center,
.header,
.footer,
.content {
  display: flex;
  align-items: center;
  justify-content: center;
}

.full {
  height: 100%;
}
</style>

API

Props

NameTypeDefaultDescription
stickybooleanfalseWhether to stick the sidebar to the top. See Sticky layout for usage notes.
collapsiblebooleanfalseWhether to show the expand/collapse button of the sidebar.
collapsedbooleanfalse

.sync

The state of collapsing or expanding the sidebar.

autocollapsebooleanfalseWhether to automatically collapse the sidebar when the window is stretched to a certain threshold.
collapse-mode'slim' | 'hidden''slim'The collapse mode, which can be slim (partially collapsed) or hidden (completely collapsed).

Slots

NameDescription
defaultThe content of the sidebar.
Edit this page on GitHubEdit
© Baidu, Inc. 2024