@s-ui/react-atom-switch

2.1.0 • Public • Published

AtomSwitch

The switch is the radio button when there’re only 2 exclusive options. “On/off” is a common and clear example for explaining this component.

In order to collect the result of this switch there is a callback onToggle, this callback receives a flag on true if select is active. If you're using a select type of this component, false means the first option and true the second one.

There are several two sizes for this component: default and large.

documentation issue npm

Issues open NPM

Installation

$ npm install @s-ui/react-atom-switch --save

Usage

Basic usage - Uncontrolled component

import AtomSwitch from '@s-ui/react-atom-switch'

return (
  <AtomSwitch
    disabled={false}
    initialValue={false}
    isFitted={false}
    isLoading={true}
    label="Label"
    labelLeft="Off"
    labelOptionalText="Optional label"
    labelRight="On"
    onToggle={flag => console.log(`Switch value is ${flag}`)}
    size="default"
    type="toggle"
  />
)

Basic usage - Controlled component

import AtomSwitch from '@s-ui/react-atom-switch'

return (
  <AtomSwitch
    labelLeft="Off"
    labelRight="On"
    onToggle={value => handleChangeFromParent(value)}
    type="toggle"
    value={value}
  />
)

Find full description and more examples in the demo page.

Package Sidebar

Install

npm i @s-ui/react-atom-switch

Weekly Downloads

1,160

Version

2.1.0

License

MIT

Unpacked Size

31.4 kB

Total Files

11

Last publish

Collaborators

  • alejandro.ferrante
  • ivanmlaborda
  • salvador.juan
  • andresin87.adevinta
  • izeller
  • gfabregoadv
  • a.ferrer
  • ignacio_navarro
  • oscar_ramirez
  • jordi.munoz
  • joanleon-adv
  • aitor.rodriguez
  • luis-garrido
  • jenifer.lopez
  • isabelgomez87
  • pa.chruscinski.ext
  • schibstedspain
  • alfredo.arronte
  • belen.santos
  • xavi_ballestar
  • ferrangbtw
  • jamile.radloff
  • davidmartin2108
  • sergi.quintela
  • estefania_garcia
  • carlosvillu-adevinta
  • miriam-gil
  • arnau.guell
  • ferran.simon
  • victor.perez.adevinta
  • mariapaula.forero.ext
  • oscar.gomez
  • david.nieto
  • oriol.puig
  • nacho_torrella
  • xavi.murcia
  • ignacio.rodriguez
  • francisco.ruiz.lloret
  • sziauberyte
  • alfredo.zimperz
  • andresadv
  • javiauso
  • alverd004
  • marian.lucaci
  • pablogs
  • alisa_bayanova
  • cristhianb
  • sergiocollado
  • pablo.rey-adevinta
  • beatrizip
  • alex.castells
  • david.cuadrado.ext
  • giovanny.sayas.ext
  • patricio.sartore
  • azahara
  • marc.benito
  • sergio.escano
  • cristina.rodriguez.duque
  • pol.valls
  • frandelacasa-adevinta
  • carolina.mallo.ext
  • daniel.perez.ext
  • hpintos_adevinta
  • carlos.gonzalezl
  • albert.peiro
  • oscar-raig-adevinta
  • thomas.page.ext
  • sebastian.badea.adevinta
  • victoria.pasichnyk.ext
  • sendami.luque.ext
  • luz_adv
  • alfredo.narvaez
  • ruben-martin
  • dann41
  • emiliovz
  • adria.velardos
  • arturo.vicente
  • diegomr
  • sergi.martinez.adevinta
  • guillemgc3
  • frontend-jobs
  • javiermiguel
  • atilioscolaroadv
  • crotundu.adevinta
  • candymd
  • florinz
  • denis_z
  • anya_ok