Select 2

Select

Select is a form control, that after the click displays a collapsible list of multiple values which can be used in forms, menus or surveys.

Select enables you to use ↑ and ↓ arrow keys to navigate through options and use ↵ key to select required option (works for stateful select).

Select Button

Pro Component
select2Img
import React from "react";
import { CDBSelect2, CDBContainer } from "cdbreact";
export const Select = () => {
const [option] = useState([
{
text: "Select Option",
icon:"stack-overflow",
},
{
text: "Another Option",
icon:"reddit",
},
{
text: "Option 3",
icon:"instagram",
},
{
text: "Option 4",
},
{
text: "Last Option",
},
]);
return (
<CDBContainer>
<CDBSelect2 options={option} iconBrand selected="Choose an option" color="white"/>
</CDBContainer>
);
};

Disable Select Button

Pro Componentselect2Img2
import React from "react";
import { CDBSelect2, CDBContainer } from "cdbreact";
export const Select = () => {
const [option] = useState([
{
text: "Select Option",
icon:"stack-overflow",
},
{
text: "Another Option",
icon:"reddit",
},
{
text: "Option 3",
icon:"instagram",
},
{
text: "Option 4",
},
{
text: "Last Option",
},
]);
return (
<CDBContainer>
<CDBSelect2 options={option} iconBrand selected="Choose an option" disabled color="none" />
</CDBContainer>
);
};

Colored Select Button

Pro Componentselect2Img3
import React from "react";
import { CDBSelect2, CDBContainer } from "cdbreact";
export const Select = () => {
const [option] = useState([
{
text: "Select Option",
icon:"stack-overflow",
},
{
text: "Another Option",
icon:"reddit",
},
{
text: "Option 3",
icon:"instagram",
},
{
text: "Option 4",
},
{
text: "Last Option",
},
]);
return (
<CDBContainer>
<CDBSelect2 options={option} iconBrand selected="Choose an option" color="primary" />
<CDBSelect2 options={option} iconBrand selected="Choose an option" color="secondary" />
<CDBSelect2 options={option} iconBrand selected="Choose an option" color="success" />
<CDBSelect2 options={option} iconBrand selected="Choose an option" color="warning" />
<CDBSelect2 options={option} iconBrand selected="Choose an option" color="dark" />
</CDBContainer>
);
};
## Colored Buttons with HoverPro Componentselect2Img4
import React from "react";
import { CDBSelect2, CDBContainer } from "cdbreact";
export const Select = () => {
const [option] = useState([
{
text: "Select Option",
icon:"stack-overflow",
},
{
text: "Another Option",
icon:"reddit",
},
{
text: "Option 3",
icon:"instagram",
},
{
text: "Option 4",
},
{
text: "Last Option",
},
]);
return (
<CDBContainer>
<CDBSelect2 options={option} iconBrand selected="Choose an option" hoverColor color="danger" />
</CDBContainer>
);
};

CDBSelect

Pro Component
import React from "react";
import { CDBSelect, CDBContainer } from "cdbreact";
export const Select = () => {
const option = useState([
{
text: "Select Option",
icon:"stack-overflow",
},
{
text: "Another Option",
icon:"reddit",
},
{
text: "Option 3",
icon:"instagram",
},
{
text: "Option 4",
},
{
text: "Last Option",
},
]);
return (
<CDBContainer>
<CDBSelect selected="Options" options={option}/>
</CDBContainer>
);
};

API

In this section you will find advanced information about the Select 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 Select Import Statement

You need to import the Contrast Select component first before using it.

import { CDBSelect2 } from "cdbreact";

API Reference: Contrast Select Properties

The table below shows the configuration options of the CDBSelect2 component.

NameTypeDefaultDescriptionExample
classNameStringAdds custom classes<CDBSelect2 className="myClass" ... />
tagStringdivChanges default tag<CDBSelect2 tag="div" ... />
disableBooleanfalseIf true - the option wont be clickable.<CDBSelect2 disabled .../>
colorStringSets colorful hover effect on select options.<CDBSelect2 color="primary" ... />
iconSizeStringSets size of icon brand in select option<CDBSelect2 iconSize="20px" ... />
iconBrandBooleanfalseadds icon to the select option<CDBSelect2 iconBrand .../>
iconLightBooleanfalseSets the icon light<CDBSelect2 iconLight .../>
iconRegularBooleanfalseSets the icon regular<CDBSelect2 iconRegular .../>
iconClassStringAdds custom class to icon<CDBSelect2 iconClass="myClass" ... />
optionsArray of ObjectsSets options array as source of data. This property is used in alternative Select version.<CDBSelect2 options={options}" ... />
hoverColorBooleanfalseSets hover effect on select options.<CDBSelect2 hoverColor .../>
selectedStringSet default select text content.<CDBSelect2 selected="Choose one" ... />
optionClassNameStringAdds custom classes to options<CDBSelect2 optionClassName="my-class" ... />