Skip to content

Commit 1171032

Browse files
authored
Update README.md
1 parent d096bff commit 1171032

File tree

1 file changed

+28
-35
lines changed

1 file changed

+28
-35
lines changed

README.md

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,22 @@ Install:
1717
```bash
1818
npm install vue-js-toggle-button --save
1919
```
20-
If using `vue-cli`, add the SASS loader:
21-
```bash
22-
npm install sass-loader node-sass --save-dev
23-
```
2420

25-
Import Plugin:
21+
Import plugin:
22+
2623
```javascript
2724
import ToggleButton from 'vue-js-toggle-button'
2825
Vue.use(ToggleButton)
2926
```
27+
**OR**
28+
29+
Import component:
30+
31+
```javascript
32+
import { ToggleButton } from 'vue-js-toggle-button
33+
Vue.component('ToggleButton', ToggleButton);
34+
```
35+
3036
Use:
3137
```xml
3238
<toggle-button @change="onChangeEventHandler"/>
@@ -42,43 +48,40 @@ Use:
4248
:labels="{checked: 'Foo', unchecked: 'Bar'}"/>
4349
```
4450
45-
If you prefer not to use the plugin you can also import the component directly:
46-
```javascript
47-
import ToggleButton from 'vue-js-toggle-button/src/Button.vue''
48-
```
49-
5051
### Properties
5152
52-
| Name | Type | Default | Description |
53-
| --- | --- | --- | --- |
54-
| value | Boolean | false | Initial state of the toggle button |
55-
| sync | Boolean | false | If set to `true`, will be watching changes in `value` property and overwrite the current state of the button whenever `value` prop changes |
56-
| speed | Number | 300 | Transition time for the animation |
57-
| disabled | Boolean | false | Button does not react on mouse events |
58-
| color | [String, Object] | `#75C791` | If `String` - color of the button when checked <br>If `Object` - colors for the button when checked/unchecked or disabled<br>Example: `{checked: '#00FF00', unchecked: '#FF0000', disabled: '#CCCCCC'}` |
59-
| cssColors | Boolean | false | If `true` - deactivates the setting of colors through inline styles in favor of using CSS styling |
60-
| labels | [Boolean, Object] | false | If `Boolean` - shows/hides default labels ("on" and "off") <br>If `Object` - sets custom labels for both states. <br>Example: `{checked: 'Foo', unchecked: 'Bar'}` |
61-
| 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)'}` |
62-
| width | Number | 50 | Width of the button, default is 50 |
63-
| height | Number | 22 | Height of the button, default is 22 |
64-
| name | String | undefined | Name to attach to the generated input field |
65-
66-
`labels` object accepts HTML text (for example, you can use FontAwesome for checked/unchecked states).
53+
| Name | Type | Default | Description |
54+
| --- | --- | --- | --- |
55+
| value | Boolean | false | Initial state of the toggle button |
56+
| sync | Boolean | false | If set to `true`, will be watching changes in `value` property and overwrite the current state of the button whenever `value` prop changes |
57+
| speed | Number | 300 | Transition time for the animation |
58+
| disabled | Boolean | false | Button does not react on mouse events |
59+
| color | [String, Object] | `#75C791` | If `String` - color of the button when checked <br>If `Object` - colors for the button when checked/unchecked or disabled<br>Example: `{checked: '#00FF00', unchecked: '#FF0000', disabled: '#CCCCCC'}` |
60+
| cssColors | Boolean | false | If `true` - deactivates the setting of colors through inline styles in favor of using CSS styling |
61+
| labels | [Boolean, Object] | false | If `Boolean` - shows/hides default labels ("on" and "off") <br>If `Object` - sets custom labels for both states. <br>Example: `{checked: 'Foo', unchecked: 'Bar'}` |
62+
| 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)'}` |
63+
| width | Number | 50 | Width of the button |
64+
| height | Number | 22 | Height of the button |
65+
| name | String | undefined | Name to attach to the generated input field |
66+
| fontSize | Number | undefined | Font size |
6767
6868
### Events
6969
7070
| Name | Description |
7171
| --- | --- |
7272
| change | Triggered whenever state of the component changes. <br>Contains: <br>`value` - state of the object <br>`srcEvent` - source click event |
73+
| input | Input event for v-model |
7374
7475
### SSR
7576
7677
Include plugin in your `nuxt.config.js` file:
78+
7779
```javascript
7880
module.exports = {
7981
plugins: ['~plugins/vue-js-toggle-button']
8082
}
8183
```
84+
8285
And your `plugins/vue-js-toggle-button.js` will look like:
8386
8487
```javascript
@@ -95,13 +98,3 @@ Vue.use(Button)
9598
* Safari: 10+
9699
* IE: 11+
97100
98-
### Font size
99-
To change font size please use basic css:
100-
```css
101-
.vue-js-switch#changed-font {
102-
font-size: 16px;
103-
}
104-
```
105-
```vue
106-
<toggle-button id="changed-font"/>
107-
```

0 commit comments

Comments
 (0)