Checkbox
Checkbox
Checkbox is a component used for allowing a user to make a multiple choice. Broadly used in the forms and surveys.
Checkboxes are for selecting one or several options in a list, while radios are for selecting one option from many.
Examples
Default Checkbox example.
import React from "react";import { CDBInput, CDBContainer } from "cdbreact";const Checkbox = () => {return (<CDBContainer><CDBInput type="checkbox"/></CDBContainer>);};export default Checkbox;
CDBCheckbox
Pro Componentimport React from "react";import { CDBCheckbox, CDBContainer } from "cdbreact";const Checkbox = () => {return (<CDBContainer><CDBCheckbox/></CDBContainer>);};export default Checkbox;
Disabled state
Pro ComponentSimply add the disabled boolean attribute to CDBCheckbox
import React from "react";import { CDBCheckbox, CDBContainer } from "cdbreact";const Checkbox = () => {return (<CDBContainer><CDBCheckbox disabled/></CDBContainer>);};export default Checkbox;
API
In this section you will find advanced information about the Checkbox 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 Checkbox Import Statement
You need to import the Contrast Checkbox component first before using it.
import { CDBCheckbox } from "cdbreact";
API Reference: Contrast Checkbox Properties
The table below shows the configuration options of the CDBCheckbox component.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| className | String | Adds custom classes | <CDBCheckbox className="myClass" ... /> | |
| tag | String | div | Changes default input tag | <CDBCheckbox tag="input" ... /> |
| disable | Boolean | false | Disables Checkbox component | <CDBCheckbox disabled .../> |