Switch
Switch
Switch is a simple component used for activating one of two predefined options. Commonly used as an on/off button.
It's mostly used in a number of various forms since they are dead simple to use and cut the time one needs to fill all the inputs.
Examples
Switch example.
import React from "react";import { CDBSwitch, CDBContainer } from "cdbreact";export const Switch = () => {return (<CDBContainer><CDBSwitch /><CDBSwitch checked /></CDBContainer>);};
API
In this section you will find advanced information about the Switch component. You will find out which modules are required, what are the possibilities of configuring the component, and what events and methods you can use to work with it.
Contrast Switch Import Statement
You need to import the Contrast Switch component first before using it.
import { CDBSwitch } from "cdbreact";
API Reference: Contrast Switch Properties
The table below shows the configuration options of the CDBSwitch component.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| tag | String | div | Changes default input tag | <CDBSwitch tag="div" ... /> |
| checked | Boolean | false | Sets the initial state of switch to ON | <CDBSwitch checked .../> |