New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

svelte-switch

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-switch

Svelte component for toggle button

0.0.5
latest
Source
npm
Version published
Maintainers
1
Created
Source

svelte-switch

NPM npm bundle size (minified + gzip)

SvelteJS component for switch or toggle a boolean. User would be able to drag or click for toggling.

Demo

Click here for Storybook link

REPL Link

Installation

npm install svelte-switch

or

yarn add svelte-switch

Usage

<script>
  import Switch from "svelte-switch";

  let checkedValue = true;

  function handleChange(e) {
    const { checked } = e.detail;
    checkedValue = checked;
  }
</script>

<h1>Simple usage</h1>
Switch with default style
<Switch on:change={handleChange} checked={checkedValue} />
<br />
The switch is {checkedValue ? 'on' : 'off'}.

API

Props

Prop NameDescriptionDefault Value
checkedRequired fieldundefined
disabledfalse
offColor"#888"
onColor"#080"
offHandleColor"#fff"
onHandleColor"#fff"
handleDiameter0
boxShadownull
activeBoxShadow"0 0 2px 3px #3bf"
height28
width56
id''
containerClass''

Slots

Slot NameDescriptionDefault Set?
checkedIconYes
unCheckedIconYes

Events

Event NameDescriptionevent.detail info
change{event: event, checked}

Examples

Click here to view stories implementation

Credits

Component is reimplementation react-switch. Complete credit goes to author and contributors of react-switch.

License

MIT

Keywords

svelte

FAQs

Package last updated on 26 Sep 2021

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