Example
<div>
<wui-side-panel
:visible="true"
title="Custom panel title"
>
<template v-slot:sidenav>
<div class="p-x-15 p-y-10">Sidenav</div>
</template>
<template v-slot:default="panel">
<wui-container fluid>
<wui-row>
<wui-col md="8">
<wui-panel class="m-t-15">
<wui-panel-body>
<h3>Side panel content</h3>
</wui-panel-body>
</wui-panel>
</wui-col>
<wui-col md="4">
<wui-panel class="m-t-15" panel-title="Widget">
<wui-panel-body>
<p class="m-b-30">Some nice widget content</p>
</wui-panel-body>
</wui-panel>
</wui-col>
</wui-row>
</wui-container>
</template>
<template v-slot:action-bar="panel">
<wui-toolbelt class="border-0 w-full">
<wui-toolbelt-bar class="align-items-center p-x-15">
<span class="wui-color--gray-46">1 of 4</span>
<div class="wui-inline-list">
<div class="wui-inline-list__item">
<wui-quick-pagination
class="panel-heading__pagination wui-pagination"
light
:limit="1"
:total-rows="4"
/>
</div>
<div class="wui-inline-list__item">
<a
title="Delete item"
class="wui-btn wui-btn--outline wui-btn--default"
v-w-tooltip.hover
>
<i class="fa fa-trash"></i>
</a>
</div>
</div>
</wui-toolbelt-bar>
</wui-toolbelt>
</template>
<template v-slot:footer>footer (optional slot)</template>
</wui-side-panel>
</div>
import { WuiSidePanel } from "@wui/wui-vue/lib/side-panel";
Description
The <wui-side-panel>
component is a UI modified modal which is intended to display more detailed data record positions. It is used in combination with a table that shows data records that can be opened and edited by the user in the side panel without leaving the actual page.
Available in WuiVue since v.3.0.3
.
<template>
<div>
<wui-button variant="primary" @click="handleBtnOpenEvent"
>{ panelShow ? "Close" : "Open" } demo side panel</wui-button
>
<wui-side-panel
v-model="panelShow"
id="customSidePanel"
title="Side panel title"
>
Side panel default slot
</wui-side-panel>
</div>
</template>
<script>
export default {
data() {
return {
panelShow: false,
};
},
};
</script>
Overview
The side panel component is based on the WUI Modal and therefore supports some ot its features (see the component reference).
You can override the side-panel title via the named slot title
, override the header completely via the header
slot.
Toggle side-panel visibility
There are several methods that you can employ to toggle the visibility of <wui-side-panel/>
.
Using v-model
property
v-model
property is always automatically synced withv-model
.
<template>
<div>
<wui-button @click="sidePanelShow = !sidePanelShow"
>Open Side Panel</wui-button
>
<wui-side-panel v-model="sidePanelShow"
>Hello From Side Panel!</wui-side-panel
>
</div>
</template>
<script>
export default {
data() {
return {
sidePanelShow: false,
};
},
};
</script>
When using the v-model
prop, do not use the visible
prop at the same time.
Using show()
, hide()
, and toggle()
component methods
You can access modal using ref attribute and then call the show()
, hide()
or toggle()
methods.
<template>
<div>
<wui-button id="show-btn" @click="showSidePanel"
>Open Side Panel</wui-button
>
<wui-button id="toggle-btn" @click="toggleSidePanel"
>Toggle Side Panel</wui-button
>
<wui-side-panel ref="my-side-panel" title="Using Component Methods">
<div class="display--block text--center">
<h3>Hello From My Side Panel!</h3>
</div>
<wui-button
class="mt-3"
variant="danger"
outline
block
@click="hideSidePanel"
>Close Me</wui-button
>
<wui-button
class="mt-2"
variant="warning"
outline
block
@click="toggleSidePanel"
>Toggle Me</wui-button
>
</wui-side-panel>
</div>
</template>
<script>
export default {
methods: {
showSidePanel() {
this.$refs["my-side-panel"].show();
},
hideSidePanel() {
this.$refs["my-side-panel"].hide();
},
toggleSidePanel() {
// We pass the ID of the button that we want to return focus to
// when the side panel has hidden
this.$refs["my-side-panel"].toggle("#toggle-btn");
},
},
};
</script>
The hide()
method accepts an optional string trigger
argument for defining what triggered the side panel to close. See section Prevent Closing in the modal documentation for details.
Side panel content
Using the side menu
The side panel offers the possibility to display an extended menu in an extra column (slot sidenav
). The menu should contain navigation items that lead to similar items that are shown in detail in the content area.
Since the side menu and the content area are created by you, it is your responsibility to create the click handling accordingly (click in the left menu changes the content area and the title).
<template>
<div>
<wui-button @click="sidePanelShow = !sidePanelShow"
>Open Side Panel</wui-button
>
<wui-side-panel v-model="sidePanelShow" :title="title">
<template #sidenav>
<ul>
<li><a href="#" @click.prevent="handleClick(1)">Item 1</a></li>
<li><a href="#" @click.prevent="handleClick(2)">Item 1</a></li>
</ul>
</template>
<template #default>Show details of item #{ currentItem }</template>
</wui-side-panel>
</div>
</template>
<script>
export default {
data() {
return {
sidePanelShow: false,
currentItem: 1,
};
},
computed: {
title() {
return `Item #${this.currentItem}`;
},
},
methods: {
handleClick(itemId) {
this.currentItem = itemId;
},
},
};
</script>
If you use the sidenav
slot, a button is automatically displayed in the header to open and close the side menu. The tooltip text of the button can be changed with the two side panel props titleSideNavHide
and titleSideNavShow
.
Side panel size
The width of the side panel depends on whether the wescale menu is collapsed or expanded.
The side panel also offers the option of expanding the panel across the entire width of the page, whereby the wescale menu will always remain visible. Using an expand button in the side panel, the user can expand the panel or reset it to its normal state.
The initial status can be set via the expanded
property:
<template>
<div>
<wui-button variant="primary" @click="handleBtnOpenEvent"
>{ panelShow ? "Close" : "Open" } demo side panel</wui-button
>
<wui-side-panel
v-model="panelShow"
title="Side panel title"
:expanded="true"
>
Side panel in expanded state
</wui-side-panel>
</div>
</template>
<script>
export default {
data() {
return {
panelShow: false,
};
},
};
</script>
The expand
property is ignored as soon as the user changes the expand status via the corresponding button. The side panel event expand
with the new status as event parameter (true
or false
) will be emitted as soon as the status is changed by the user.
Component reference
<wui-side-panel>
Properties
The side panel component is based on the WUI Modal and supports the following modal prop features:
bodyClass
,busy
,contentClass
,dialogClass
,footerClass
,headerClass
,hideBackdrop
,id
,lazy
,modalClass
,noCloseOnBackdrop
,noCloseOnEsc
,noEnforceFocus
,returnFocus
,static
,title
,titleClass
,titleTag
,visible
(v-model),
All other attributes and WUI modal event listeners are supported and forwarded to the wui-modal
component. This means that all events triggered by the modal are also supported.
Property | Type | Default | Description |
---|---|---|---|
expanded | Boolean | false | Sets the side panel in expand mode which expands the widths of the panel to the left. The widths depends on whether the wescale menu is open or not |
hideTooltips | Boolean | false | Disabled the tooltips for side panel icon buttons close , expand and toggel-sidenav |
sideNavOpen | Boolean | false | Renders the side panel with a side nav initially open |
titlePanelClose | String | Close [ESC] | The tooltip title for the 'close' button |
titlePanelCollapse | String | Collapse view | The tooltip title for the 'expand/collapse' button when expanded state is true |
titlePanelExpand | String | Expand view | The tooltip title for the 'expand/collapse' button when expanded state is false |
titleSideNavHide | String | Hide items list | The tooltip title for the sidenav 'toggle' button when sidenav is open |
titleSideNavShow | String | Hide items list | The tooltip title for the sidenav 'toggle' button when sidenav is closed |
actionBarClass | String | null | The class for the wrapper div of action bar slot |
v-model
Property | Event |
---|---|
visible | change |
Slots
Name | Scoped | Description |
---|---|---|
action-bar | See package.json for scope | Side panel action buttons area. If header slot is used, this slot will not be shown. Optionally scoped |
default | See package.json for scope | Content of side panel body. Optionally scoped |
footer | See package.json for scope | Side panel footer content. Optionally scoped |
header | See package.json for scope | Entire side panel header container contents. Also removes the left toggle-sidenav button. Optionally scoped |
header-item-{n} | See package.json for scope | 1 or more content items you want to place next to the side panel 'expand' and 'close' buttons in the header. {n} is the number of the slot item (e.g. header-item-1 ). You can pass as much slot items as you want, just increase the {n} number |
sidenav | See package.json for scope | Side panel sidenav content. Optionally scoped |
side-panel-busy | No | Optional slot to place loading message when side panel is in the busy stat |
title | See package.json for scope | Side panel title. If header slot is used, this slot will not be shown. Optionally scoped |
Events
Event | Arguments | Description |
---|---|---|
expand | expanded - The expanded state of the side panel. true if the side panel is expanded and false if collapsed | Always emits when expanded status is changed by the user |
toggle-sidenav | sideNavOpen - The expanded state of the sidenav. true if the sidenav is expanded and false if collapsed | Always emits when sideNavOpen status is changed by the user |
Importing as a Vue.js plugin
This plugin includes all of the above listed individual components. Plugins also include any component aliases.
Named Export | Import Path |
---|---|
SidePanelPlugin | @wui/wui-vue/lib/side-panel |
Example
import { SidePanelPlugin } from "@wui/wui-vue/lib/side-panel";
Vue.use(SidePanelPlugin);