{"id":13681686,"url":"https://github.com/euvl/vue-js-toggle-button","last_synced_at":"2025-05-14T10:14:39.501Z","repository":{"id":18914878,"uuid":"85564440","full_name":"euvl/vue-js-toggle-button","owner":"euvl","description":":fish_cake: Vue.js 2 toggle / switch button - simple, pretty, customizable","archived":false,"fork":false,"pushed_at":"2022-12-11T09:59:54.000Z","size":834,"stargazers_count":933,"open_issues_count":51,"forks_count":133,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-13T10:50:22.761Z","etag":null,"topics":["button","javascript","switch","toggle-buttons","toggle-switches","vue","vue-component","vue-plugin","vuejs"],"latest_commit_sha":null,"homepage":"http://vue-js-toggle-button.yev.io/","language":"Vue","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/euvl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"euvl"}},"created_at":"2017-03-20T10:34:34.000Z","updated_at":"2025-02-28T03:02:34.000Z","dependencies_parsed_at":"2022-08-07T13:00:05.338Z","dependency_job_id":null,"html_url":"https://github.com/euvl/vue-js-toggle-button","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euvl%2Fvue-js-toggle-button","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euvl%2Fvue-js-toggle-button/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euvl%2Fvue-js-toggle-button/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euvl%2Fvue-js-toggle-button/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/euvl","download_url":"https://codeload.github.com/euvl/vue-js-toggle-button/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254120179,"owners_count":22017953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["button","javascript","switch","toggle-buttons","toggle-switches","vue","vue-component","vue-plugin","vuejs"],"created_at":"2024-08-02T13:01:34.389Z","updated_at":"2025-05-14T10:14:39.478Z","avatar_url":"https://github.com/euvl.png","language":"Vue","readme":"\u003cspan\u003e\n  \u003cimg src=\"https://badge.fury.io/js/vue-js-toggle-button.svg\"\u003e\n\u003c/span\u003e \u003cspan\u003e\n  \u003cimg src=\"https://img.shields.io/npm/dm/vue-js-toggle-button.svg\"\u003e\n\u003c/span\u003e \n\n# Vue.js toggle/switch button.\n\n\u003cp align=\"right\"\u003e\n  \u003ca href=\"https://www.buymeacoffee.com/yev\" target=\"_blank\"\u003e\n    \u003cimg\n         width=\"140\"\n         alt=\"Get a coffee\"\n         src=\"https://user-images.githubusercontent.com/1577802/36840220-21beb89c-1d3c-11e8-98a4-45fc334842cf.png\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"http://i.imgur.com/a2Hf7pm.png\"\u003e\n\u003c/p\u003e\n\n[Live demo here](http://vue-js-toggle-button.yev.io/)\n\n### Install\n\n```bash\nnpm install vue-js-toggle-button --save\n```\n\n### Import\n\nImport plugin:\n\n```javascript\nimport ToggleButton from 'vue-js-toggle-button'\n\nVue.use(ToggleButton)\n```\n**OR**\n\nImport component:\n\n```javascript\nimport { ToggleButton } from 'vue-js-toggle-button'\n\nVue.component('ToggleButton', ToggleButton)\n```\n\n### Use\n\n```xml\n\u003ctoggle-button @change=\"onChangeEventHandler\"/\u003e\n\n\u003ctoggle-button v-model=\"myDataVariable\"/\u003e\n\n\u003ctoggle-button :value=\"false\"\n               color=\"#82C7EB\"\n               :sync=\"true\"\n               :labels=\"true\"/\u003e\n\n\u003ctoggle-button :value=\"true\"\n               :labels=\"{checked: 'Foo', unchecked: 'Bar'}\"/\u003e\n```\n\n### Properties\n\n| Name            | Type              | Default     | Description                        |\n| ---             | ---               | ---         | ---                                |\n| value           | Boolean           | false       | Initial state of the toggle button |\n| 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 |\n| speed           | Number            | 300        | Transition time for the animation   |\n| disabled        | Boolean           | false      | Button does not react on mouse events |\n| color           | [String, Object]  | `#75C791`  | If `String` - color of the button when checked \u003cbr\u003eIf `Object` - colors for the button when checked/unchecked or disabled\u003cbr\u003eExample: `{checked: '#00FF00', unchecked: '#FF0000', disabled: '#CCCCCC'}`  |\n| css-colors       | Boolean           | false      | If `true` - deactivates the setting of colors through inline styles in favor of using CSS styling |\n| labels          | [Boolean, Object] | false      | If `Boolean` - shows/hides default labels (\"on\" and \"off\") \u003cbr\u003eIf `Object` - sets custom labels for both states. \u003cbr\u003eExample: `{checked: 'Foo', unchecked: 'Bar'}`   |\n| switch-color     | [String, Object]  | `#BFCBD9`  | If `String` - color or background property of the switch when checked \u003cbr\u003eIf `Object` - colors or background property for the switch when checked/uncheked \u003cbr\u003eExample: `{checked: '#25EF02', unchecked: 'linear-gradient(red, yellow)'}`   |\n| width           | Number            | 50         | Width of the button |\n| height          | Number            | 22         | Height of the button |\n| margin          | Number            | 3          | Space between the switch and background border |\n| name            | String            | undefined  | Name to attach to the generated input field |\n| font-size        | Number            | undefined  | Font size |\n\n### Events\n\n| Name   | Description              |\n| ---    | ---                      |\n| change | Triggered whenever state of the component changes. \u003cbr\u003eContains: \u003cbr\u003e`value` - state of the object \u003cbr\u003e`srcEvent` - source click event |\n| input  | Input event for v-model |\n\n### SSR\n\nInclude plugin in your `nuxt.config.js` file:\n\n```javascript\nmodule.exports = {\n  plugins: ['~plugins/vue-js-toggle-button']\n}\n```\n\nAnd your `plugins/vue-js-toggle-button.js` will look like:\n\n```javascript\nimport Vue from 'vue'\nimport Button from 'vue-js-toggle-button'\n\nVue.use(Button)\n```\n\n### Browser compatibility\n\n* Chrome: 40+\n* Firefox: 25+\n* Safari: 10+\n* IE: 11+\n\n","funding_links":["https://github.com/sponsors/euvl","https://www.buymeacoffee.com/yev"],"categories":["Vue","UI Components [🔝](#readme)","Awesome Vue.js [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)","UI组件","Components \u0026 Libraries","UI Components"],"sub_categories":["Libraries \u0026 Plugins","形成","UI Components","Form"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuvl%2Fvue-js-toggle-button","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feuvl%2Fvue-js-toggle-button","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuvl%2Fvue-js-toggle-button/lists"}