1.4.1 • Published 5 months ago

jb-switch v1.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

jb-switch

Published on webcomponents.org GitHub license NPM Downloads

switch web-component with these benefits:

  • support loading state
  • pure js and ready to use
  • beautiful animation
  • customizable with your style with just css variable

using with JS frameworks

to use this component in react see jb-switch/react;

usage

npm i jb-switch
<jb-switch true-title="my enable" false-title="my-disable"></jb-switch>

set loading

document.querySelector("jb-switch").isLoading = true; //true or false

get/set value

alert(document.querySelector("jb-switch").value);
document.querySelector("jb-switch").value = true; //true or false

set custom style

in some cases in your project you need to change default style of web-component for example you need zero margin or different border-radius and etc.
if you want to set a custom style to this web-component all you need is to set css variable in parent scope of web-component.

usage example:

body{
  //if you want to change color of switch 
  --jb-switch-bg-color-active: green;
}

variable list

css variable namedescription
--jb-switch-bg-color-activebackground color of switch when value is true
--jb-switch-bg-colorbackground color of switch when value is false
--jb-switch-ring-colortrigger ring color when value is false
--jb-switch-ring-color-activetrigger ring color when value is true

Other Related Docs:

1.2.0

7 months ago

1.4.1

5 months ago

1.2.3

7 months ago

1.4.0

5 months ago

1.3.1

6 months ago

1.2.2

7 months ago

1.3.0

7 months ago

1.2.1

7 months ago

1.1.1

1 year ago

1.1.2

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago