Vue playground

Nova v3.38.0

Preview

Vue

Collapsing and resizing

The icon rail, the open binding in each framework, and the resize handle.

A sidebar is persistent by default: always expanded. Set type="collapsible" to let people shrink it to an icon rail, and resizable to let them drag its edge.

Collapse

Collapse#

type="collapsible" adds a toggle button to the sidebar's edge. open holds the state and starts as true. It only has an effect on a collapsible sidebar.

openChanged reports every change of open on a collapsible sidebar, whether it came from the toggle or from your code. Its detail is the new value. Use it to keep your own state in step:

v-model binds open.

vue<NvSidebar type="collapsible" v-model="open">…</NvSidebar>

Any other control can change open too, like the Toggle navigation button in the example.

What the rail shows#

A collapsed sidebar keeps the icons and hides the rest:

  • Item labels, group labels and trailing content are hidden. Give every top-level item an icon, and keep the icons distinct.
  • A notification count moves onto the item's icon.
  • Open sub-menus are closed, and stay closed when the sidebar expands again. A parent whose sub-item is the current page is highlighted in its place.
  • Clicking an item follows its link. That is also true for a parent with sub-items, since it cannot open in the rail.
  • The logo shows its collapsedLogo and hides the name.

Hide your own content in the rail with the data-hide-on-collapsed attribute. It works on any element inside the sidebar:

vue<NvSidebarfooter>
  <p data-hide-on-collapsed>Signed in as Mina Patel</p>
</NvSidebarfooter>

Resize#

resizable adds a handle on the sidebar's right edge. It is not shown while the sidebar is collapsed.

WhatHow
PointerDrag the edge.
KeyboardFocus the edge. Left and Right move it by 8 px, Home and End jump to the limits.
LimitsminWidth and maxWidth, in pixels. They default to 200 and 480.
Current widthwidth, in pixels. Set it to start at a width other than the theme's.
Hearing about itwidthChanged, at the end of a drag and after each keyboard step, not during the drag.

To remember the width, store the value from widthChanged and pass it back in width.

Use v-model:width beside v-model for open.