Select List
Although <select />
supports attribute multiple to let user select multiple options.
But the UI will become list and can't hide anymore.
It is not easy for user to know press ctrl & click for multi-select option.
<msc-select-list />
provides a common UI as <select /> and group checkboxs as its drop menu.
So user could experience it as usual and have multi-select feature.
Try to select the following examples to see what can <msc-select-list />
do ?
Normal
Option selected
Top 3 Options disabled
Basic Usage
<msc-select-list />
is a web component. All we need to do is put the required script into your HTML document. Then follow <msc-select-list />
's html structure and everything will be all set.
Required Script
Structure
Put <msc-select-list />
into HTML document. It will have different functions and looks with attribute mutation.
Otherwise, developers could also choose remoteconfig to fetch config for <msc-select-list />
.
JavaScript Instantiation
<msc-select-list />
could also use JavaScript to create DOM element. Here comes some examples.
Storage
<msc-select-list />
will generate an input[type=hidden] as storage and put success selected options' value data as its value. <input /> default name is msc-select-list
, developers can switch any name they liked.
Style Customization
Developers could apply styles to decorate <msc-select-list />
's looking.
Attributes
<msc-select-list />
supports some attributes to let it become more convenience & useful.
options
Set options for <msc-select-list />
. It should be JSON string. Each element sholud contain content & value (checked & disabled are optional). Default is [] (not set).
placeholder
Set placeholder for <msc-select-list />
. Default is select please (not set).
size
Set size for <msc-select-list />
. Drop menu apply size for how many options display in a fold (max). Default is 5 (not set).
sound
Set sound effect for <msc-select-list />
when drop menu tapped.
vibrate
Set vibrate effect for <msc-select-list />
when drop menu tapped.
Property
Property Name | Type | Description |
---|---|---|
options
|
Array | Getter / Setter for options. Each element sholud contain content & value (checked & disabled are optional). Default is [] .ex :selectList.options = [{ content:'option1', value:'option1'}]; |
values
|
Array | Getter / Setter for values.ex :selectList.values = ['option1', 'option2']; |
placeholder
|
String | Getter / Setter for placeholder. <msc-select-list /> will display this value when no option selected. Default is select please . |
size
|
Number | Getter / Setter for size. Drop menu apply size for how many options display in a fold (max). Default is 5 . |
sound
|
Boolean | Getter / Setter for sound. Set sound effect or not when drop menu tapped. Default is false . |
vibrate
|
Boolean | Getter / Setter for vibrate. Set vibrate effect or not when drop menu tapped. Default is false . |
Event
Event Signature | Description |
---|---|
msc-select-list-change
|
Fired when user select option. |