Switch
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';
Switch
Change the initial setting of the switch to be on by using the 'checked' property.
import React from 'react';import { CDBSwitch, CDBContainer } from 'cdbreact';
export const Switch = () => { return ( <CDBContainer> <CDBSwitch /> <CDBSwitch checked /> </CDBContainer> );};
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.`.
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 .../> |
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.