Socket
Socket
Sign inDemoInstall

@lion/switch

Package Overview
Dependencies
Maintainers
1
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lion/switch

A Switch is used for switching a property or feature on and off


Version published
Maintainers
1
Created
Source

Switch >> Overview ||10

The Switch is used to toggle a property or feature on or off.

import { html as previewHtml } from '@mdjs/mdjs-preview';
import '@lion/switch/define-switch';
import { html, LitElement, ScopedElementsMixin } from '@lion/core';
import { LionSwitch } from '@lion/switch';

class MyComponent extends ScopedElementsMixin(LitElement) {
  static get scopedElements() {
    return { 'lion-switch': LionSwitch };
  }
  render() {
    return html`<lion-switch label="Label" help-text="Help text"></lion-switch>`;
  }
}
customElements.define('my-component', MyComponent);

export const main = () => previewHtml`<my-component></my-component>`;

When to use

  • Toggling the component on or off has an immediate action (no confirmation by the user required).
  • The Switch is typically used in setting applications.
  • The Switch is not a Checkbox in disguise and can not be used as part of a form.

Features

  • Get or set the checked state (boolean) - checked boolean attribute
  • Pre-select an option by setting the checked boolean attribute
  • Get or set the value of the choice - choiceValue()

How to use

Code

  1. Install
npm i --save @lion/switch
  1. Use scoped registry
import { html, LitElement, ScopedElementsMixin } from '@lion/core';
import { LionSwitch } from '@lion/switch';

class MyComponent extends ScopedElementsMixin(LitElement) {
  static get scopedElements() {
    return { 'lion-switch': LionSwitch };
  }
  render() {
    return html`<lion-switch></lion-switch>`;
  }
}
  1. Use html
<script type="module">
  import '@lion/switch/define-switch';
</script>

<lion-switch></lion-switch>

Keywords

FAQs

Package last updated on 09 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc