@cig/switch

React Switch Control

Usage no npm install needed!

<script type="module">
  import cigSwitch from 'https://cdn.skypack.dev/@cig/switch';
</script>

README

@cig/switch

The Switch control for React.

Demo

https://codesandbox.io/s/cigswitch-mlnkr

Installation and usage

The easiest way to use @cig/switch is to install it from npm and build it into your app with Webpack.

npm i -S @cig/switch

Then use it in your App:

import React, {
  useState,
} from 'react'
import Switch from '@cig/switch'


export default () => {
  const [value, setValue] = useState(true)

  return (
    <Switch
      value={value}
      update={v => setValue(v)}
    />
  )
}

Props

名称 类型 必填 默认值 描述
value Array N - 默认选项
update Function N - 数据更新回调