Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
vuejs-toggle-switch
Advanced tools
A toggle switch component for Vue.js
Weekly downloads
Readme
Toggle switch for vue.js
v2.0.0
Do you have questions or want a new feature? Use the "Issues" section :point_left:
NB! Version 1.2.32 and later use rem instead of px NM! Version 2.0.0 and later use value prop.
install:
npm install vuejs-toggle-switch --save
Import: (in your main.js)
import ToggleSwitch from 'vuejs-toggle-switch'
Vue.use(ToggleSwitch)
Use: (in your local .vue file/component, html section)
<toggle-switch
:options="myOptions"
:disabled="false" // optional, can use here on top level or in config section
@change="updateMap($event.value)" // This is optional
@selected="selectedMethod()" // This is optional
v-model="selectedMapOption" // This is optional 2-way binding (try not to use both 1-way and 2-way)
:value="selectedMapOption" // This is optional 1-way binding (try not to use both 1-way and 2-way)
:name="name" // This is optional for input block
:group="switchGroup" // This is optional, use if multiple toggle-switch on same page with same label names
/>
<!-- Options struct: -->
myOptions: {
layout: {
color: 'black',
backgroundColor: 'lightgray',
selectedColor: 'white',
selectedBackgroundColor: 'green',
borderColor: 'black',
fontFamily: 'Arial',
fontWeight: 'normal',
fontWeightSelected: 'bold',
squareCorners: false,
noBorder: false
},
size: {
fontSize: 14,
height: 34,
padding: 7,
width: 100
},
config: {
delay: .4,
preSelected: 'unknown',
disabled: false,
items: [
{ name: 'Off', value: 'Off', color: 'white', backgroundColor: 'red' },
{ name: 'On', value: 'On', color: 'white', backgroundColor: 'green' }
]
}
}
Name | Type | Default | Description |
---|---|---|---|
width | Number | 10 | Width of labels |
height | Number | 3.25 | Height |
padding | Number | 0.5 | Adjust text location in item with this |
backgroundColor | String | lightgray | Background color (not selected) |
color | String | black | Text color (not selected) |
borderColor | String | gray | border color |
selectedColor | String | white | Text color selected item |
selectedBackgroundColor | String | green | Selected item background color |
fontFamily | String | Arial | Font of item text |
fontWeight | String | normal | Font weight item (not selected) |
fontWeightSelected | String | bold | Font weight selected item |
fontSize | Number | 1.5 | Text size |
disabled | Boolean | false | Disable switch |
preSelected | String | On | Set (pre) selected item |
items | Array | Off/On | Items for switch, name and value (string) mandatory |
value | String | n/a | Value, ie: v-model="selectedMapOption" |
delay | Number | .4 | Transition delay between labels is seconds |
squareCorners | Boolean | false | Rounded corners of switch |
noBorder | Boolean | false | Remove border |
group | String | '' | Switch key/group name (optional) |
name | String | '' | Name for input field (optional) can be used as ref for forms etc |
disabled (prop) | Boolean | false | Disable switch on top level (prop) |
Labels prop can be used with or without color and backgroundColor attr, if not used the common prop: selectedColor and selectedBackgroundColor will be used for all labels.
Name | Description |
---|---|
change | Triggered on toggle, user selects switch option, returns current value. @change="vmValueItem = $event.value" |
selected | Triggered whenever user select switch item |
input | Triggered on mount if preSelected is set or value is set, and on toggle/change |
FAQs
A toggle switch component for Vue.js
The npm package vuejs-toggle-switch receives a total of 427 weekly downloads. As such, vuejs-toggle-switch popularity was classified as not popular.
We found that vuejs-toggle-switch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.