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
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 Componentimport 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 Component
## Colored Buttons with HoverPro Componentimport 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>);};

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 Componentimport 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.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| className | String | Adds custom classes | <CDBSelect2 className="myClass" ... /> | |
| tag | String | div | Changes default tag | <CDBSelect2 tag="div" ... /> |
| disable | Boolean | false | If true - the option wont be clickable. | <CDBSelect2 disabled .../> |
| color | String | Sets colorful hover effect on select options. | <CDBSelect2 color="primary" ... /> | |
| iconSize | String | Sets size of icon brand in select option | <CDBSelect2 iconSize="20px" ... /> | |
| iconBrand | Boolean | false | adds icon to the select option | <CDBSelect2 iconBrand .../> |
| iconLight | Boolean | false | Sets the icon light | <CDBSelect2 iconLight .../> |
| iconRegular | Boolean | false | Sets the icon regular | <CDBSelect2 iconRegular .../> |
| iconClass | String | Adds custom class to icon | <CDBSelect2 iconClass="myClass" ... /> | |
| options | Array of Objects | Sets options array as source of data. This property is used in alternative Select version. | <CDBSelect2 options={options}" ... /> | |
| hoverColor | Boolean | false | Sets hover effect on select options. | <CDBSelect2 hoverColor .../> |
| selected | String | Set default select text content. | <CDBSelect2 selected="Choose one" ... /> | |
| optionClassName | String | Adds custom classes to options | <CDBSelect2 optionClassName="my-class" ... /> |