Skip to content

Commit 3e87f52

Browse files
authored
Merge pull request #76 from ajhaupt7/master
Add support for setting the input's name attribute
2 parents 6f47955 + 76c351c commit 3e87f52

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<a align="right" href="https://www.buymeacoffee.com/yev" target="_blank">
55
<img width="200" alt="screen shot 2018-03-01 at 10 33 39" src="https://user-images.githubusercontent.com/1577802/36840220-21beb89c-1d3c-11e8-98a4-45fc334842cf.png">
66
</a>
7-
7+
88
### Vue.js 2 toggle / switch button - simple, pretty, customizable.
99

1010
![Imgur](http://i.imgur.com/a2Hf7pm.png)
@@ -33,12 +33,12 @@ Use:
3333

3434
<toggle-button v-model="myDataVariable"/>
3535

36-
<toggle-button :value="false"
37-
color="#82C7EB"
38-
:sync="true"
36+
<toggle-button :value="false"
37+
color="#82C7EB"
38+
:sync="true"
3939
:labels="true"/>
4040

41-
<toggle-button :value="true"
41+
<toggle-button :value="true"
4242
:labels="{checked: 'Foo', unchecked: 'Bar'}"/>
4343
```
4444

@@ -61,6 +61,7 @@ import ToggleButton from 'vue-js-toggle-button/src/Button'
6161
| switchColor | [String, Object] | `#BFCBD9` | If `String` - color or background property of the switch when checked <br>If `Object` - colors or background property for the switch when checked/uncheked <br>Example: `{checked: '#25EF02', unchecked: 'linear-gradient(red, yellow)'}` |
6262
| width | Number | 50 | Width of the button, default is 50 |
6363
| height | Number | 22 | Height of the button, default is 22 |
64+
| name | String | undefined | Name to attach to the generated input field |
6465

6566
`labels` object accepts HTML text (for example, you can use FontAwesome for checked/unchecked states).
6667

demo/src/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<toggle-button :labels="true" color="#82C7EB"/>
1313

1414
<toggle-button :value="true"
15+
name="phone"
1516
:labels="{checked: 'Android', unchecked: 'iPhone'}"
1617
:color="{checked: '#7DCE94', unchecked: '#82C7EB'}"
1718
:width="80"/>
@@ -34,7 +35,7 @@
3435
:color="{unchecked: '#FF6699'}"
3536
:labels="{unchecked: 'Disabled button'}"
3637
:disabled="true"/>
37-
38+
3839
<toggle-button :value="true"
3940
:labels="{checked: 'Button', unchecked: 'Collor'}"
4041
:color="{checked: '#7DCE94', unchecked: '#82C7EB'}"

src/Button.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
:aria-checked="ariaChecked">
55
<input type="checkbox"
66
class="v-switch-input"
7+
:name="name"
78
@change.stop="toggle">
89
<div class="v-switch-core"
910
:style="coreStyle">
@@ -53,6 +54,9 @@ export default {
5354
type: Boolean,
5455
default: false
5556
},
57+
name: {
58+
type: String
59+
},
5660
sync: {
5761
type: Boolean,
5862
default: false

0 commit comments

Comments
 (0)