@anypoint-web-components/anypoint-switch
TypeScript icon, indicating that this package has built-in type declarations

0.1.13 • Public • Published

Deprecated

This component has been moved to anypoint-web-components/awc.


Switches toggle the state of a single setting on or off. They are the preferred way to adjust settings on mobile.

This component is based on Material Design switch and adjusted for Anypoint platform components.

Anypoint web components are set of components that allows to build Anypoint enabled UI in open source projects.

Published on NPM

tests

Usage

Installation

npm install --save @anypoint-web-components/anypoint-switch

In an html file

<html>
  <head>
    <script type="module">
      import './node_modules/@anypoint-web-components/anypoint-switch/anypoint-switch.js';
    </script>
  </head>
  <body>
    <anypoint-switch>on/of</anypoint-switch>
    <script>
    {
      document.querySelector('anypoint-switch').onchange = () => {
        // ...
      };
    }
    </script>
  </body>
</html>

In a LitElement

import { LitElement, html } from 'lit-element';
import '@anypoint-web-components/anypoint-switch/anypoint-switch.js';

class SampleElement extends PolymerElement {
  render() {
    return html`
    <anypoint-switch
      .checked="${this.checked}"
      @change="${this._switchHandler}">on/off</anypoint-switch>
    `;
  }

  _switchHandler(e) {
    this.checked = e.detail.value;
  }
}
customElements.define('sample-element', SampleElement);

Development

git clone https://github.com/anypoint-web-components/anypoint-switch
cd anypoint-switch
npm install

Running the demo locally

npm start

Running the tests

npm test

Package Sidebar

Install

npm i @anypoint-web-components/anypoint-switch

Weekly Downloads

446

Version

0.1.13

License

Apache-2.0

Unpacked Size

24.1 kB

Total Files

13

Last publish

Collaborators

  • jarrodek
  • twoplustwoone
  • lbauret
  • carowright