{"id":15024343,"url":"https://github.com/gitbrent/bootstrap-switch-button","last_synced_at":"2025-08-31T21:36:15.937Z","repository":{"id":34493014,"uuid":"166593755","full_name":"gitbrent/bootstrap-switch-button","owner":"gitbrent","description":"Bootstrap 4 plugin/widget that converts checkboxes into responsive toggles.","archived":false,"fork":false,"pushed_at":"2022-10-18T13:44:07.000Z","size":2979,"stargazers_count":34,"open_issues_count":11,"forks_count":16,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-20T21:41:09.226Z","etag":null,"topics":["bootstrap-checkbox","bootstrap-switch","bootstrap-switch-widget","bootstrap-toggle","bootstrap4","twitter-bootstrap"],"latest_commit_sha":null,"homepage":"https://gitbrent.github.io/bootstrap-switch-button/","language":"HTML","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/gitbrent.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-19T21:07:37.000Z","updated_at":"2024-08-12T15:07:09.000Z","dependencies_parsed_at":"2022-08-29T07:20:43.103Z","dependency_job_id":null,"html_url":"https://github.com/gitbrent/bootstrap-switch-button","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/gitbrent/bootstrap-switch-button","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbrent%2Fbootstrap-switch-button","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbrent%2Fbootstrap-switch-button/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbrent%2Fbootstrap-switch-button/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbrent%2Fbootstrap-switch-button/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gitbrent","download_url":"https://codeload.github.com/gitbrent/bootstrap-switch-button/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbrent%2Fbootstrap-switch-button/sbom","scorecard":{"id":427974,"data":{"date":"2025-08-11","repo":{"name":"github.com/gitbrent/bootstrap-switch-button","commit":"836a6977232f518125025b92464512f85fa8be31"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.5,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 1/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v1.0.0 not signed: https://api.github.com/repos/gitbrent/bootstrap-switch-button/releases/16594922","Warn: release artifact v1.0.0 does not have provenance: https://api.github.com/repos/gitbrent/bootstrap-switch-button/releases/16594922"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"15 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-957j-59c2-j692","Warn: Project is vulnerable to: GHSA-m5pj-vjjf-4m3h","Warn: Project is vulnerable to: GHSA-j383-35pm-c5h4","Warn: Project is vulnerable to: GHSA-rm36-94g8-835r","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T02:40:03.481Z","repository_id":34493014,"created_at":"2025-08-19T02:40:03.481Z","updated_at":"2025-08-19T02:40:03.481Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273046347,"owners_count":25036175,"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","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bootstrap-checkbox","bootstrap-switch","bootstrap-switch-widget","bootstrap-toggle","bootstrap4","twitter-bootstrap"],"created_at":"2024-09-24T20:00:09.156Z","updated_at":"2025-08-31T21:36:15.907Z","avatar_url":"https://github.com/gitbrent.png","language":"HTML","readme":"[![MIT Licence](https://img.shields.io/github/license/gitbrent/bootstrap-switch-button.svg)](https://opensource.org/licenses/mit-license.php) [![Bootstrap 4.3.1](https://img.shields.io/badge/bootstrap-4.3.1-green.svg?style=flat-square)](https://getbootstrap.com/docs/4.1) [![Known Vulnerabilities](https://snyk.io/test/npm/bootstrap-switch-button/badge.svg)](https://snyk.io/test/npm/bootstrap-switch-button) [![Package Quality](https://npm.packagequality.com/shield/bootstrap-switch-button.svg)](https://packagequality.com/#?package=bootstrap-switch-button) [![JSDelivr Badge](https://data.jsdelivr.com/v1/package/gh/gitbrent/bootstrap-switch-button/badge)](https://www.jsdelivr.com/package/gh/gitbrent/bootstrap-switch-button)\n\n# Bootstrap Switch Button\n\n**Bootstrap Switch Button** converts plain checkboxes into awesome switch buttons.\n\n---\n\n#### Library Distributions\n\n| Project                                                                                    | Description                                             |\n| ------------------------------------------------------------------------------------------ | ------------------------------------------------------- |\n| [bootstrap4-toggle](https://github.com/gitbrent/bootstrap4-toggle)                         | Supports bootstrap4 (requires jQuery)                   |\n| [bootstrap-switch-button](https://github.com/gitbrent/bootstrap-switch-button)             | Supports bootstrap4+ (ES6 class, no dependencies)       |\n| [bootstrap-switch-button-react](https://github.com/gitbrent/bootstrap-switch-button-react) | Supports bootstrap4+ (React component, no dependencies) |\n\n# Demos\n\n**Demos and API Docs:** https://gitbrent.github.io/bootstrap-switch-button/\n\n![Demo GIF](https://github.com/gitbrent/bootstrap-switch-button/blob/master/demo/assets/bootstrap-switch-button-demo.gif?raw=true)\n\n# Installation\n\n## CDN\n\n```html\n\u003clink\n  href=\"https://cdn.jsdelivr.net/gh/gitbrent/bootstrap-switch-button@1.1.0/css/bootstrap-switch-button.min.css\"\n  rel=\"stylesheet\"\n/\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/gitbrent/bootstrap-switch-button@1.1.0/dist/bootstrap-switch-button.min.js\"\u003e\u003c/script\u003e\n```\n\n## Download\n\n[Latest GitHub Release](https://github.com/gitbrent/bootstrap-switch-button/releases/latest)\n\n## NPM\n\n```ksh\nnpm i bootstrap-switch-button\n```\n\n## Yarn\n\n```ksh\nyarn add bootstrap-switch-button\n```\n\n# Usage\n\n## Initialize With HTML\n\nSimply add `data-toggle=\"switchbutton\"` to automatically convert a plain checkbox into a bootstrap 4 switch button.\n\n```html\n\u003cinput id=\"chkSwitch\" type=\"checkbox\" data-toggle=\"switchbutton\" /\u003e\n```\n\n## Initialize With Code\n\nSwitch buttons can also be initialized via JavaScript code.\n\nEX: Initialize id `chkSwitch` with a single line of JavaScript.\n\n```html\n\u003cinput id=\"chkSwitch\" type=\"checkbox\" checked /\u003e\n\u003cscript\u003e\n  $(function() {\n    $(\"#chkSwitch\").switchbutton();\n  });\n\u003c/script\u003e\n```\n\n# API\n\n## Options\n\n- Options can be passed via data attributes or JavaScript\n- For data attributes, append the option name to `data-` (ex: `data-onlabel=\"Enabled\"`)\n\n```html\n\u003cinput\n  type=\"checkbox\"\n  data-toggle=\"switchbutton\"\n  data-onlabel=\"Enabled\"\n  data-offlabel=\"Disabled\"\n/\u003e\n\u003cinput type=\"checkbox\" id=\"switch-two\" /\u003e\n\u003cscript\u003e\n  $(function() {\n    $(\"#switch-two\").switchButton({\n      onlabel: \"Enabled\",\n      offlabel: \"Disabled\"\n    });\n  });\n\u003c/script\u003e\n```\n\n| Name       | Type        | Default   | Description                                                                                                                                   |\n| ---------- | ----------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------- |\n| `onlabel`  | string/html | \"On\"      | Text of the on switch button                                                                                                                  |\n| `offlabel` | string/html | \"Off\"     | Text of the off switch button                                                                                                                 |\n| `onstyle`  | string      | \"primary\" | Style of the on switch button. Possible values are: `primary`,`secondary`,`success`,`danger`,`warning`,`info`,`light`,`dark`                  |\n| `offstyle` | string      | \"light\"   | Style of the off switch button. Possible values are: `primary`,`secondary`,`success`,`danger`,`warning`,`info`,`light`,`dark`                 |\n| `size`     | string      | \"normal\"  | Size of the switch button. Possible values are: `large`, `normal`, `small`, `mini`.                                                           |\n| `style`    | string      |           | Appends the value to the class attribute of the switch button. This can be used to apply custom styles. Refer to Custom Styles for reference. |\n| `width`    | integer     | _null_    | Sets the width of the switch button. if set to _null_, width will be auto-calculated.                                                         |\n| `height`   | integer     | _null_    | Sets the height of the switch button. if set to _null_, height will be auto-calculated.                                                       |\n\n## Methods\n\nMethods can be used to control switch buttons directly.\n\n```html\n\u003cinput id=\"switch-demo\" type=\"checkbox\" data-toggle=\"switchbutton\" /\u003e\n```\n\n| Method     | Example                                     | Description                                       |\n| ---------- | ------------------------------------------- | ------------------------------------------------- |\n| initialize | `$('#switch-demo').switchButton()`          | Initializes the switch button plugin with options |\n| destroy    | `$('#switch-demo').switchButton('destroy')` | Destroys the switch button                        |\n| on         | `$('#switch-demo').switchButton('on')`      | Sets the switch button to 'On' state              |\n| off        | `$('#switch-demo').switchButton('off')`     | Sets the switch button to 'Off' state             |\n| toggle     | `$('#switch-demo').switchButton('toggle')`  | Toggles the state of the switch button on/off     |\n| enable     | `$('#switch-demo').switchButton('enable')`  | Enables the switch button                         |\n| disable    | `$('#switch-demo').switchButton('disable')` | Disables the switch button                        |\n\n# Events\n\n## Event Propagation\n\nNote All events are propagated to and from input element to the switch button.\n\nYou should listen to events from the `\u003cinput type=\"checkbox\"\u003e` directly rather than look for custom events.\n\n```html\n\u003cinput id=\"switch-event\" type=\"checkbox\" data-toggle=\"switchbutton\" /\u003e\n\u003cdiv id=\"console-event\"\u003e\u003c/div\u003e\n\u003cscript\u003e\n  $(function() {\n    $(\"#switch-event\").change(function() {\n      $(\"#console-event\").html(\"Checked?: \" + $(this).prop(\"checked\"));\n    });\n  });\n\u003c/script\u003e\n```\n\n## API vs Input\n\nThis also means that using the API or Input to trigger events will work both ways.\n\n```html\n\u003cinput id=\"switch-trigger\" type=\"checkbox\" data-toggle=\"switchbutton\" /\u003e\n\u003cbutton class=\"btn btn-success\" onclick=\"toggleApiOn()\"\u003eOn by API\u003c/button\u003e\n\u003cbutton class=\"btn btn-danger\" onclick=\"toggleApiOff()\"\u003eOff by API\u003c/button\u003e\n\u003cbutton class=\"btn btn-success\" onclick=\"toggleInpOn()\"\u003eOn by Input\u003c/button\u003e\n\u003cbutton class=\"btn btn-danger\" onclick=\"toggleInpOff()\"\u003eOff by Input\u003c/button\u003e\n\u003cscript\u003e\n  function toggleApiOn() {\n    $(\"#switch-trigger\").switchButton(\"on\");\n  }\n  function toggleApiOff() {\n    $(\"#switch-trigger\").switchButton(\"off\");\n  }\n  function toggleInpOn() {\n    $(\"#switch-trigger\")\n      .prop(\"checked\", true)\n      .change();\n  }\n  function toggleInpOff() {\n    $(\"#switch-trigger\")\n      .prop(\"checked\", false)\n      .change();\n  }\n\u003c/script\u003e\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitbrent%2Fbootstrap-switch-button","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgitbrent%2Fbootstrap-switch-button","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitbrent%2Fbootstrap-switch-button/lists"}