{"bugs":{"url":"https://github.com/material-components/material-components-web/issues"},"dist":{"shasum":"e83f6689640a92e6afbf697316642037b26910a7","tarball":"https://registry.npmjs.org/@material/switch/-/switch-9.0.0-canary.30fdfd06e.0.tgz","fileCount":38,"integrity":"sha512-g6i2pwxMVlWEnaVBcetJ35JXgZ8DBHCShrdvt31Je/UnkOYu2zgrhSpQKimMfoyNQtxZbzEQMWP9ZlWylZ0apw==","signatures":[{"sig":"MEUCIA7zxH49MZPiPb/Q6pr3wyAMtI9QDCPvhZmcAFIoouU/AiEA45tY3pcb0btaorBQzPQmPqsoJTu0XrIXD1GbyYVWkOQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":490080,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf2lr3CRA9TVsSAnZWagAAcckP/ilYBqSp3yzzyQF8uiMd\njWZKsmos1f0xnKcNu5qAU6akbdmYQv8R8o0PZOUNycpk3jnnyU052yl7+Ukj\nLN9RBFW/CUGemStMDVBeW9MCvrvp6uvq1/qeEt/o2L23fVS06Bs6fSl7dAno\nwgckkU5WfJWJDjllx51zgh9OHbDVfp0IiGu7wJreg3o0O2AVRnN6wOanHK+H\npxk4RDJDHw/RMhoG7p5pK8QY5QxDXVL2SbOJt3u+c9uquBFS3VJELFReVrp6\nYKCXtzfHhRImCvAYdiI0Si8JLmXC6SO2vfGOsghQ1YjHP9shl9ExPDMd2lhX\njbMQTeCjDgcBRwbLge5NxwPdrIVvIxyyB1S5X+/g6ri6ZD6iH7aDTQ1D3JYG\n9vl4TrUkm1X+cCloVkd/KnVRt1dGboHABxNnDQqdrF+lsir/hp3Snz/YC5sq\nF67eHRjmAyZMmQfGGOxbfNv+4fbZg3PqFu4EfvV+yap7ewjbIo2g6v7jKeea\nckRIu+ZXTE9sO83KOzB/sze7UKQORoRpI+iLPBgO09sOD7IX/hAFEXO/nd3I\n3KNHhs3v3kdS1ySeivV2Oh8qCjMO7ozPgIFBpXJtMwpvryGw59nDSwsuZdx6\nWQegT/U1IGVnkHHOjX1gnP9aE/2Fmf/xj88P8QyAspSPd8dJxYLGiTtTcvxz\nI7/w\r\n=6Kvh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/mdc.switch.js","name":"@material/switch","types":"dist/mdc.switch.d.ts","module":"index.js","readme":"<!--docs:\ntitle: \"Switches\"\nlayout: detail\nsection: components\niconId: switch\npath: /catalog/input-controls/switches/\n-->\n\n# Selection controls: switches\n\n[Selection controls](https://material.io/components/selection-controls#usage) allow the user to select options.\n\nSwitches toggle the state of a single setting on or off. They are the preferred way to adjust settings on mobile.\n\n![Switch hero example for menu options](images/switch-hero.png)\n\n**Contents**\n\n* [Using switches](#using-switches)\n* [Switches](#switches)\n* [Other variants](#other-variants)\n* [API](#api)\n* [Usage within web frameworks](#usage-within-web-frameworks)\n\n## Using switches\n\nUse switches to:\n\n* Toggle a single item on or off, on mobile and tablet\n* Immediately activate or deactivate something\n\n### Installing switches\n\n```\nnpm install @material/switch\n```\n\n### Styles\n\n```scss\n@use \"@material/switch\";\n\n@include switch.core-styles;\n```\n\n### JavaScript instantiation\n\nThe switch requires JavaScript to function, so it is necessary to instantiate `MDCSwitch` on the `mdc-switch` element.\n\n```js\nimport {MDCSwitch} from '@material/switch';\n\nconst switchControl = new MDCSwitch(document.querySelector('.mdc-switch'));\n```\n\n**Note: See [Importing the JS component](../../docs/importing-js.md) for more information on how to import JavaScript.**\n\n## Switches\n\n### Switch example\n\n```html\n<div class=\"mdc-switch\">\n  <div class=\"mdc-switch__track\"></div>\n  <div class=\"mdc-switch__thumb-underlay\">\n    <div class=\"mdc-switch__thumb\"></div>\n    <input type=\"checkbox\" id=\"basic-switch\" class=\"mdc-switch__native-control\" role=\"switch\" aria-checked=\"false\">\n  </div>\n</div>\n<label for=\"basic-switch\">off/on</label>\n```\n\n### Switch states\n\nSwitches can be on or off. Switches have enabled, hover, focused, and pressed states.\n\n![Switch states in a table. Columns are enabled, disabled, hover, focused, pressed. Rows are on or off.](images/switch-states.png)\n\n## Other variants\n\n### Initially disabled switch\n\nAdd the `mdc-switch--disabled` class to the `mdc-switch` element, and the `disabled` attribute to the `mdc-switch__native-control` element to disable the switch. This logic is handled by the `MDCSwitchFoundation.setDisabled` method, but you'll want to avoid a FOUC by initially adding this class and attribute.\n\n```html\n<div class=\"mdc-switch mdc-switch--disabled\">\n  <div class=\"mdc-switch__track\"></div>\n  <div class=\"mdc-switch__thumb-underlay\">\n    <div class=\"mdc-switch__thumb\"></div>\n    <input type=\"checkbox\" id=\"another-basic-switch\" class=\"mdc-switch__native-control\" role=\"switch\" aria-checked=\"false\" disabled>\n  </div>\n</div>\n<label for=\"another-basic-switch\">off/on</label>\n```\n\n### Initially \"on\" switch\n\nAdd the `mdc-switch--checked` class to the `mdc-switch` element, and the `checked` attribute to the `mdc-switch__native-control` element to toggle the switch to \"on\". This logic is handled by the `MDCSwitchFoundation.setChecked` method, but you'll want to avoid a FOUC by initially adding this class and attribute.\n\n```html\n<div class=\"mdc-switch mdc-switch--checked\">\n  <div class=\"mdc-switch__track\"></div>\n  <div class=\"mdc-switch__thumb-underlay\">\n    <div class=\"mdc-switch__thumb\"></div>\n    <input type=\"checkbox\" id=\"another-basic-switch\" class=\"mdc-switch__native-control\" role=\"switch\" aria-checked=\"true\" checked>\n  </div>\n</div>\n<label for=\"another-basic-switch\">off/on</label>\n```\n\n## API\n\n### CSS classes\n\nCSS Class | Description\n--- | ---\n`mdc-switch` | Mandatory, for the parent element.\n`mdc-switch--disabled` | Optional, styles the switch as disabled\n`mdc-switch--checked` | Optional, styles the switch as checked (\"on\")\n`mdc-switch__track` | Mandatory, for the track element.\n`mdc-switch__thumb-underlay` | Mandatory, for the ripple effect.\n`mdc-switch__thumb` | Mandatory, for the thumb element.\n`mdc-switch__native-control` | Mandatory, for the hidden input checkbox.\n\n### Sass mixins\n\nMDC Switch uses [MDC Theme](../mdc-theme)'s `secondary` color by default for the checked (toggled on) state.\nUse the following mixins to customize _enabled_ switches. It is not currently possible to customize the color of a\n _disabled_ switch. Disabled switches use the same colors as enabled switches, but with a different opacity value.\n\nMixin | Description\n--- | ---\n`toggled-on-color($color)` | Sets the base color of the track, thumb, and ripple when the switch is toggled on.\n`toggled-off-color($color)` | Sets the base color of the track, thumb, and ripple when the switch is toggled off.\n`toggled-on-track-color($color)` | Sets color of the track when the switch is toggled on.\n`toggled-off-track-color($color)` | Sets color of the track when the switch is toggled off.\n`toggled-on-thumb-color($color)` | Sets color of the thumb when the switch is toggled on.\n`toggled-off-thumb-color($color)` | Sets color of the thumb when the switch is toggled off.\n`toggled-on-ripple-color($color)` | Sets the color of the ripple surrounding the thumb when the switch is toggled on.\n`toggled-off-ripple-color($color)` | Sets the color of the ripple surrounding the thumb when the switch is toggled off.\n`ripple-size($ripple-size)` | Sets the ripple size of the switch.\n`density($density-scale)` | Sets density scale for switch. Supported density scales are `-5`, `-4`, `-3`, `-2`, `-1`, and `0` (default).\n`ripple-states-opacity($opacity-map)` | Sets the opacity of the ripple surrounding the thumb in any of the `hover`, `focus`, or `press` states. The `opacity-map` can specify any of these states as keys. States not specified in the map resort to default opacity values.\n\n### `MDCSwitch` properties and methods\n\nProperty | Value Type | Description\n--- | --- | ---\n`checked` | Boolean | Setter/getter for the switch's checked state\n`disabled` | Boolean | Setter/getter for the switch's disabled state\n\n## Usage within web frameworks\n\nIf you are using a JavaScript framework, such as React or Angular, you can create a Switch for your framework. Depending on your needs, you can use the _Simple Approach: Wrapping MDC Web Vanilla Components_, or the _Advanced Approach: Using Foundations and Adapters_. Please follow the instructions [here](../../docs/integrating-into-frameworks.md).\n\n### `MDCSwitchAdapter`\n\n| Method Signature | Description |\n| --- | --- |\n| `addClass(className: string) => void` | Adds a class to the root element. |\n| `removeClass(className: string) => void` | Removes a class from the root element. |\n| `setNativeControlChecked(checked: boolean)` | Sets the checked state of the native control. |\n| `setNativeControlDisabled(disabled: boolean)` | Sets the disabled state of the native control. |\n| `setNativeControlAttr(attr: string, value: string)` | Sets an HTML attribute to the given value on the native input element. |\n\n### `MDCSwitchFoundation`\n\n| Method Signature | Description |\n| --- | --- |\n| `setChecked(checked: boolean) => void` | Sets the checked value of the native control and updates styling to reflect the checked state. |\n| `setDisabled(disabled: boolean) => void` | Sets the disabled value of the native control and updates styling to reflect the disabled state. |\n| `handleChange(evt: Event) => void` | Handles a change event from the native control. |\n\n### `MDCSwitchFoundation` event handlers\n\nIf wrapping the switch component it is necessary to add an event handler for native control change events that calls the `handleChange` foundation method. For an example of this, see the [`MDCSwitch`](component.ts) component's `initialSyncWithDOM` method.\n\n| Event | Element Selector | Foundation Handler |\n| --- | --- | --- |\n| `change` | `.mdc-switch__native-control` | `handleChange()` |\n","gitHead":"f9c9fe091a06230b038ac8a71ccd652c7c662b96","license":"MIT","_npmUser":{"name":"abhiomkar","email":"abhiomkar@gmail.com"},"homepage":"https://github.com/material-components/material-components-web#readme","keywords":["material components","material design","switch"],"repository":{"url":"git+https://github.com/material-components/material-components-web.git","type":"git","directory":"packages/mdc-switch"},"_npmVersion":"lerna/3.20.2/node@v10.23.0+x64 (linux)","description":"The Material Components for the web switch component","directories":{},"maintainers":[{"name":"material-admin","email":"aprigogin+npm@google.com"},{"name":"abhiomkar","email":"abhiomkar@gmail.com"},{"name":"azakus","email":"dfreedm2@gmail.com"},{"name":"bicknellr","email":"bicknellr@gmail.com"},{"name":"bwobrien","email":"obrien.test@gmail.com"},{"name":"lynnjepsen","email":"lynnjepsen@google.com"},{"name":"acdvorak","email":"acdvorak@gmail.com"},{"name":"kfranqueiro","email":"kenneth.franqueiro@gmail.com"},{"name":"aprigogin","email":"andrey.prigogin@gmail.com"},{"name":"patrickrodee","email":"prodee@google.com"},{"name":"bonniez","email":"bonniez@google.com"},{"name":"moog16","email":"mattgoo@gmail.com"},{"name":"williamernest","email":"williamernest@google.com"},{"name":"aomarks","email":"aomarks@gmail.com"},{"name":"emarquez","email":"emarquez@google.com"},{"name":"allanchen","email":"allanchen@google.com"},{"name":"esgonzalez","email":"esgonzalez@google.com"},{"name":"asyncliz","email":"asyncliz@gmail.com"},{"name":"candysonya","email":"wangchan518@gmail.com"},{"name":"ssuarez","email":"sayrisuarez@google.com"},{"name":"taylorv","email":"brian.t.vann@gmail.com"}],"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"tslib":"^1.9.3","@material/dom":"9.0.0-canary.30fdfd06e.0","@material/rtl":"9.0.0-canary.30fdfd06e.0","@material/base":"9.0.0-canary.30fdfd06e.0","@material/theme":"9.0.0-canary.30fdfd06e.0","@material/ripple":"9.0.0-canary.30fdfd06e.0","@material/density":"9.0.0-canary.30fdfd06e.0","@material/animation":"9.0.0-canary.30fdfd06e.0","@material/elevation":"9.0.0-canary.30fdfd06e.0","@material/feature-targeting":"9.0.0-canary.30fdfd06e.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/switch_9.0.0-canary.30fdfd06e.0_1608145655305_0.0963468773521785","host":"s3://npm-registry-packages"},"_id":"@material/switch@9.0.0-canary.30fdfd06e.0","version":"9.0.0-canary.30fdfd06e.0"}