{"id":13780873,"url":"https://github.com/GoogleChromeLabs/input-knob","last_synced_at":"2025-05-11T14:34:11.206Z","repository":{"id":55102123,"uuid":"198704325","full_name":"GoogleChromeLabs/input-knob","owner":"GoogleChromeLabs","description":"A rotating, touch-sensitive knob web component that you can use like an \u003cinput type=\"range\"\u003e.","archived":true,"fork":false,"pushed_at":"2022-07-20T01:31:11.000Z","size":55,"stargazers_count":73,"open_issues_count":5,"forks_count":11,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-02T06:43:53.709Z","etag":null,"topics":["customelement","form","ui","webcomponent"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GoogleChromeLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-24T20:19:11.000Z","updated_at":"2024-07-31T08:56:23.000Z","dependencies_parsed_at":"2022-08-14T12:00:56.765Z","dependency_job_id":null,"html_url":"https://github.com/GoogleChromeLabs/input-knob","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Finput-knob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Finput-knob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Finput-knob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Finput-knob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoogleChromeLabs","download_url":"https://codeload.github.com/GoogleChromeLabs/input-knob/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225064419,"owners_count":17415241,"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":["customelement","form","ui","webcomponent"],"created_at":"2024-08-03T18:01:20.670Z","updated_at":"2024-11-17T16:30:32.689Z","avatar_url":"https://github.com/GoogleChromeLabs.png","language":"JavaScript","readme":"# `\u003cinput-knob\u003e` ⟳ custom element\n\nA rotating, touch-sensitive knob that you can use like an\n`\u003cinput type=\"range\"\u003e`.\n\n## Install\n\nThe `dist` directory contains the CommonJS module (`input-knob.cjs.js`), ES\nmodule (`input-knob.esm.js`) and UMD (`input-knob.umd.js`) variants of the\nelement that you can use directly.\n\nInstall [via npm](https://www.npmjs.com/package/input-knob) and include via the\nbundler of your choice:\n\n```sh\nnpm install --save input-knob\n```\n\nInclude via unpkg:\n\n```html\n\u003cscript src=\"https://unpkg.com/input-knob\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\nThis will create a knob with a minimum value of zero, a maximum of 100, a\ncurrent value of 50, and each full turn of the knob will change the value by 10.\n\n```html\n\u003cinput-knob value=\"50\" scale=\"10\" min=\"0\" max=\"100\"\u003e\u003c/input-knob\u003e\n```\n\n- `value`: Current value, this will update as the knob is turned. Optional,\n  defaults to `0`.\n- `scale`: The change in the value for one full turn. Optional, defaults to `1`.\n- `min`: Minimum allowed value. Optional, defaults to `null`.\n- `max`: Maxium allowed value. Optional, defaults.to `null`.\n\nIf both `min` and `max` are set, then the knob can be turned multiple times to\nreach a different `value`. If only one or none of `min` or `max` is set, then a\nfull turn of the knob will reset the value to `0`.\n\nThese are also exposed as properties on the object and can be set or observed in\nJavaScript:\n\n```javascript\nconst knob = document.querySelector('input-knob');\nknob.value = 42;\n```\n\n### Events\n\nThree event types are dispatched for each point in an interaction:\n\n- `knob-move-start`: fired on initial touch or click.\n- `knob-move-change`: fired repeatedly for each change in rotation.\n- `knob-move-end`: fired when the touch or click is released.\n\n### Style and appearance\n\nThere are two key parts of the element that can be styled. The `\u003cinput-knob\u003e`\nelement itself, which is the container for the inner `rotator` part. The\n`rotator` is accessed using the `::part(rotator)` pseudo-element. The outer\nelement does not rotate, so can be used for general positioning or changing the\nappearance of the outer container. The inner `rotator` represents the part of\nthe knob the user interacts with and will rotate as the `value` changes.\n\nContent inside the `\u003cinput-knob\u003e` tag will also rotate and can be used to do\nthings like provide a top marker for the knob.\n\n```html\n\u003cstyle\u003e\n  input-knob {\n    width: 150px;\n    padding: 10px;\n    border: 2px dashed green;\n    background: lightgreen;\n  }\n\n  input-knob::part(rotator) {\n    box-sizing: border-box;\n    background: lightblue;\n    border: 2px dashed blue;\n    border-radius: 100%;\n    width: 150px;\n    height: 150px;\n  }\n\n  .mark {\n    display: inline-block;\n    width: 100%;\n    text-align: center;\n    font: bold 200% monospace;\n    color: blue;\n  }\n\u003c/style\u003e\n\n\u003cinput-knob value=\"50\" scale=\"10\" min=\"0\" max=\"100\"\u003e\n  \u003cdiv class=\"mark\"\u003e▲\u003c/div\u003e\n\u003c/input-knob\u003e\n```\n\n![A blue knob with an upward tick on a green background](https://cdn.glitch.com/c3562722-7678-47b4-a7c3-5c26e9bc59ef%2Fstyled-knob.png?v=1566478423169)\n\n## Demo\n\nTry the demo at https://input-knob.glitch.me\n\n![An example of \u003cinput-knob\u003e in green with an upward tick indicator and slider below](https://cdn.glitch.com/c3562722-7678-47b4-a7c3-5c26e9bc59ef%2Fintpu-knob-example.png?v=1566478428792)\n\n## Backwards compatibility\n\nFor browsers that do not support custom elements, etc. you can use the\n[`webcomponents.js` polyfills](https://github.com/webcomponents/polyfills/tree/master/packages/webcomponentsjs).\n\nFor browsers that do not support Shadow Parts, the element will add a fallback\nclass and `\u003cspan\u003e` that can by styled.\n\n```css\ninput-knob {\n  width: 150px;\n  padding: 10px;\n  border: 2px dashed green;\n  background: lightgreen;\n}\n\ninput-knob::part(rotator) {\n  box-sizing: border-box;\n  background: lightblue;\n  border: 2px dashed blue;\n  border-radius: 100%;\n  width: 150px;\n  height: 150px;\n}\n\ninput-knob.fallback \u003e span.fallback {\n  display: block;\n  box-sizing: border-box;\n  background: lightblue;\n  border: 2px dashed blue;\n  border-radius: 100%;\n  width: 150px;\n  height: 150px;\n}\n```\n\n# Contributing\n\nIssues and pull requests happily received. Please see\n[CONTRIBUTING.md](CONTRIBUTING.md).\n","funding_links":[],"categories":["Form Elements"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGoogleChromeLabs%2Finput-knob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGoogleChromeLabs%2Finput-knob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGoogleChromeLabs%2Finput-knob/lists"}