React Bootstrap 5 Switch

A React Bootstrap 5 switch is a simple component that allows a user to choose between two predefined alternatives. It can serves as a responsive switch, just like the on and off switch.

Importing the React Bootstrap 5 Switch Component

Import 'CDBSwitch' into your project to use the Contrast React Bootstrap 5 Switch component.

import { CDBSwitch } from 'cdbreact';


Change the initial setting of the switch to be on by using the 'checked' property.

Contrast React Bootstrap 5 Switch
import React from 'react';
import { CDBSwitch, CDBContainer } from 'cdbreact';
export const Switch = () => {
return (
<CDBSwitch />
<CDBSwitch checked />

API Reference: Contrast React Bootstrap 5 Switch Props

This section will expand on the props you'll be using with the Contrast React Bootstrap 5 Switch component. You'll learn what these props do, how to utilize them, and what their default values are.

Other CDBSwitch prop possibilities are included in the table below.`.

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

Build modern projects using Bootstrap 5 and Contrast

Trying to create components and pages for a web app or website from scratch while maintaining a modern User interface can be very tedious. This is why we created Contrast, to help drastically reduce the amount of time we spend doing that. so we can focus on building some other aspects of the project.

Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants. Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.