{"id":13759356,"url":"https://github.com/Robdel12/checkbox","last_synced_at":"2025-05-10T09:32:25.473Z","repository":{"id":48325318,"uuid":"99638256","full_name":"Robdel12/checkbox","owner":"Robdel12","description":"Create a functional \u0026 accessibile checkbox out of pretty much any HTML markup.","archived":false,"fork":false,"pushed_at":"2021-08-01T11:14:33.000Z","size":1798,"stargazers_count":7,"open_issues_count":29,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-23T17:12:47.380Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://robdel12.github.io/checkbox/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Robdel12.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-08T01:54:51.000Z","updated_at":"2022-05-19T14:34:15.000Z","dependencies_parsed_at":"2022-08-20T10:20:48.694Z","dependency_job_id":null,"html_url":"https://github.com/Robdel12/checkbox","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Robdel12%2Fcheckbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Robdel12%2Fcheckbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Robdel12%2Fcheckbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Robdel12%2Fcheckbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Robdel12","download_url":"https://codeload.github.com/Robdel12/checkbox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253397055,"owners_count":21901985,"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":[],"created_at":"2024-08-03T13:00:51.483Z","updated_at":"2025-05-10T09:32:24.560Z","avatar_url":"https://github.com/Robdel12.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Checkbox.js [![CircleCI](https://circleci.com/gh/Robdel12/checkbox.svg?style=svg\u0026circle-token=641acbeadd66ab804551bfc7f31b053e760f1b1b)](https://circleci.com/gh/Robdel12/checkbox)\n\nCheckbox.js aims to create a functional checkbox out of pretty much\nany HTML markup. This allows you to style the checkbox any way you\nwould like. It gives you full control of the markup.\n\n\n## Getting started\n\nGiven our HTML:\n\n``` html\n\u003clabel for=\"checkbox\"\u003eSubscribe?\u003c/label\u003e\n\u003cspan id=\"checkbox\"\u003e\u003c/span\u003e\n```\n\nWe can create a new checkbox out of a span by passing the element to\ncheckbox.js:\n\n``` javascript\nnew Checkbox(document.getElementById('checkbox'));\n```\n\nThis will create a checkbox out of that HTMLElement that you\npassed. Checkbox.js will try to find a `label` element in the DOM to\nassociate with the checkbox. If it can't find a `label` it will throw\nan error. All checkboxes must have a label.\n\nWhat your checkbox should look like after using checkbox.js:\n\n``` html\n\u003clabel for=\"checkbox\" id=\"jsze4iuu8c\"\u003eSubscribe?\u003c/label\u003e\n\u003cspan id=\"checkbox\" tabindex=\"0\" role=\"checkbox\" aria-labelledby=\"jsze4iuu8c\" aria-checked=\"false\"\u003e\u003c/span\u003e\n```\n\n#### Passing a label directly\n\nIf you would like you can pass a reference to the label directly to\ncheckbox.js:\n\n``` html\n\u003clabel id=\"label\"\u003eSubscribe?\u003c/label\u003e\n\u003cspan id=\"checkbox\"\u003e\u003c/span\u003e\n```\n\n``` javascript\nnew Checkbox(document.getElementById('checkbox'), {\n  label: document.getElementById('label')\n});\n```\n\n#### Setting the initial state\n\nYou can also initialize the checkbox to be checked by default by\npassing a `isChecked` key in the `options` object.\n\n``` html\n\u003clabel id=\"label\"\u003eSubscribe?\u003c/label\u003e\n\u003cspan id=\"checkbox\"\u003e\u003c/span\u003e\n```\n\n``` javascript\nnew Checkbox(document.getElementById('checkbox'), {\n  label: document.getElementById('label'),\n  isChecked: true\n});\n```\n\n#### Programmatically change state\n\nIf you store a reference to the checkbox when you instantiate it, you\ncan call methods on that instance like `toggleCheckbox`. This allows\nyou to toggle the checkbox from actions other than a click or keyboard\nevent.\n\n``` html\n\u003clabel for=\"checkbox\"\u003eSubscribe?\u003c/label\u003e\n\u003cspan id=\"checkbox\"\u003e\u003c/span\u003e\n```\n\n``` javascript\n// init an unchecked checkbox\nlet checkbox = new Checkbox(document.getElementById('checkbox'));\n\ncheckbox.toggleCheckbox(); // toggles to checked\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRobdel12%2Fcheckbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRobdel12%2Fcheckbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRobdel12%2Fcheckbox/lists"}