Search...

Checkbox

React Bootstrap 5 Checkbox

React Bootstrap 5 Checkbox is a component that allows a user to select numerous options. It's widely used in forms and surveys.

The 'CDBInput' component or the 'CDBCheckbox' component, which comes with a specified style, can be used to create a checkbox in Contrast React Bootstrap 5 ( only available for pro users ).

Using the "CDBInput" component.

Import the 'CDBInput' component and update the value of the 'type' prop to 'checkbox' to use the default Contrast React Bootstrap 5 Checkbox component.

js
import React from "react";
import { CDBInput, CDBContainer } from "cdbreact";
const Checkbox = () => {
return (
<CDBContainer>
<CDBInput type="checkbox"/>
</CDBContainer>
);
};
export default Checkbox;

CDBCheckbox

Pro Component
js
import React from "react";
import { CDBCheckbox, CDBContainer } from "cdbreact";
const Checkbox = () => {
return (
<CDBContainer>
<CDBCheckbox/>
</CDBContainer>
);
};
export default Checkbox;

Disabled state

Pro Component

The 'disabled' property of the 'CDBCheckbox' component is set to false. To prevent the ability to click the checkbox, add the 'disabled' boolean property to 'CDBCheckbox.'

js
import React from "react";
import { CDBCheckbox, CDBContainer } from "cdbreact";
const Checkbox = () => {
return (
<CDBContainer>
<CDBCheckbox disabled/>
</CDBContainer>
);
};
export default Checkbox;

Contrast React Bootstrap 5 Checkbox Properties

This section will elaborate on the props available with the Contrast React Bootstrap 5 Checkbox component. You'll learn what these props do, how to utilize them, and what their default values are.

Other prop options for the 'CDBCheckbox' component are listed in the table below.

NameTypeDefaultDescriptionExample
classNameStringAdds custom classes<CDBCheckbox className="myClass" ... />
tagStringdivChanges default input tag<CDBCheckbox tag="input" ... />
disableBooleanfalseDisables Checkbox component<CDBCheckbox disabled .../>

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.

ad-banner