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.

switchImg
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.

NameTypeDefaultDescriptionExample
tagStringdivChanges default input tag<CDBSwitch tag="div" ... />
checkedBooleanfalseSets the initial state of switch to ON<CDBSwitch checked .../>