Skip to content

Add support for setting the input's name attribute #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<a align="right" href="https://www.buymeacoffee.com/yev" target="_blank">
<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">
</a>

### Vue.js 2 toggle / switch button - simple, pretty, customizable.

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

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

<toggle-button :value="false"
color="#82C7EB"
:sync="true"
<toggle-button :value="false"
color="#82C7EB"
:sync="true"
:labels="true"/>

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

Expand All @@ -61,6 +61,7 @@ import ToggleButton from 'vue-js-toggle-button/src/Button'
| 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)'}` |
| width | Number | 50 | Width of the button, default is 50 |
| height | Number | 22 | Height of the button, default is 22 |
| name | String | undefined | Name to attach to the generated input field |

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

Expand Down
3 changes: 2 additions & 1 deletion demo/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<toggle-button :labels="true" color="#82C7EB"/>

<toggle-button :value="true"
name="phone"
:labels="{checked: 'Android', unchecked: 'iPhone'}"
:color="{checked: '#7DCE94', unchecked: '#82C7EB'}"
:width="80"/>
Expand All @@ -34,7 +35,7 @@
:color="{unchecked: '#FF6699'}"
:labels="{unchecked: 'Disabled button'}"
:disabled="true"/>

<toggle-button :value="true"
:labels="{checked: 'Button', unchecked: 'Collor'}"
:color="{checked: '#7DCE94', unchecked: '#82C7EB'}"
Expand Down
4 changes: 4 additions & 0 deletions src/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:aria-checked="ariaChecked">
<input type="checkbox"
class="v-switch-input"
:name="name"
@change.stop="toggle">
<div class="v-switch-core"
:style="coreStyle">
Expand Down Expand Up @@ -53,6 +54,9 @@ export default {
type: Boolean,
default: false
},
name: {
type: String
},
sync: {
type: Boolean,
default: false
Expand Down