Sidebar
A sidebar provides a way to display meta content intended for temporary access (navigation links, buttons, menus, etc.). The sidebar can be revealed by a button tap while the main content remains visually underneath.
Let's take a try and see what can <msc-sidebar />
do.
Basic Usage
<msc-sidebar />
is a web component. All we need to do is put the required script into your HTML document. Then follow <msc-sidebar />
's html structure and everything will be all set.
Required Script
Structure
Put the content inside <msc-sidebar />
as its child.
When <msc-sidebar />
opened.
It will display the content with the whole viewport size.
Or set attributes directly.
Otherwise, developers could also choose remoteconfig to fetch config for
JavaScript Instantiation
<msc-sidebar />
could also use JavaScript to create DOM element. Here comes some examples.
Style Customization
<msc-sidebar />
uses CSS variables to style its interface. That means developer could easy change them into the lookup you like.
Attributes
<msc-sidebar />
supports some attributes to let it become more convenience & useful.
open
Set open for <msc-sidebar />
. Default is false (not set).
side
This attribute will positioned the content node's displayed position. There are two valid value which are "left
" and "right
".
Default is "left
".
Properties
Property Name | Type | Description |
---|---|---|
open
|
Boolean | Getter / Setter for open. Default is false . |
side
|
String | Getter / Setter for side. Valid value should be "left" or "right". Default is "left ". |
Method
Method Signature | Description |
---|---|
toggle([force])
|
Toggle <msc-sidebar /> open or not. When argument is present: If the argument is true, <msc-sidebar /> will be opened, and if it is false, close it. |
Event
Event Signature | Description |
---|---|
msc-sidebar-change
|
Fired when <msc-sidebar /> open or not. |