React Bootstrap Select
React Select - Bootstrap 4 & Material Design
Note: This documentation is for an older version of Bootstrap (v.4). A
newer version is available for Bootstrap 5. We recommend migrating to the latest version of our product - Material Design for
Bootstrap 5.
Go to docs v.5
Select enables you to use ↑
and ↓
arrow keys to
navigate through options and use ↵
key to select required option (works for stateful select).
Basic example
Select with markup usage MDB Pro component
You can bind options data from object and have full control of select component, or you can use select with markup based on HTML. This solution offers a little bit less control over the component - it won't respond on outer options changes (f.e. deletion, sorting or keyboard control).
Color variations MDB Pro component
In order to change a select color use property color
.
Select with search box MDB Pro component
Preselected options MDB Pro component
Use property checked
on an MDBSelectOption element to preselect it while component renders.
Option groups MDB Pro component
Separate groups of options using disabled option.
Select with icons MDB Pro component
Beautify your select and use icons inside option components.
Disabled select option MDB Pro component
By adding a disabled
attribute to the particular option, you can make
it unselectable.
Select Multiple MDB Pro component
Setting property multiple
allows to select the list of options. For complex
options, check Multiselect documentation
Note: Select All
option is available only within Select with Object based options.
React Select - 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.
Imports
Usage
There are two ways to bind your data into Select.
You can use regular JSX/HTML markup, or build an Array of object structured data.
API Reference: Select Properties
The table below shows the configuration options of the MDBSelect component.
Name | Type | Default | Description | Example |
---|---|---|---|---|
className |
String | "select-wrapper md-form mdb-select" |
Select wrapper classes. | <MDBSelect className="my-custom-class"> |
color |
String |
|
Sets colorfull hover efect on select options. | <MDBSelect color="primary"> |
label |
String |
|
Sets animated label for the select input. | <MDBSelect label="Example label"> |
labelClass |
String |
|
Sets custom class for select label (f.e. to change background color). | <MDBSelect labelClass="customClass"> |
multiple |
Boolean | false |
Allows to select multiple options. | <MDBSelect multiple={true}> |
options |
Array(Object) | [] |
Sets options array as source of data. This property is used in alternative Select version. | <MDBSelect options={this.state.options} /> |
outline |
Boolean | false |
Switch outline mode - Material 2.0 design with outlines and animated label. | <MDBSelect outline /> |
Next properties works only for Select with data Array! |
||||
required |
Boolean | false |
Makes select required when submitting form. | <MDBSelect required > |
search |
Boolean | false |
Search element will appear as the firs child of select. | <MDBSelect search={true}> |
searchLabel |
String | Search |
Changes default label of additional search element. | <MDBSelect searchLabel="Find option" /> |
searchId |
String | selectSearchInput |
Changes default id of additional search element. | <MDBSelect searchId="id" /> |
selected |
String |
|
Set default select text content. | <MDBSelect selected="Choose option" > |
selectAll |
Boolean | false |
Enables Select All button. |
<MDBSelect selectAll > |
selectAllClassName |
String |
|
Sets custom class for select all option (f.e. to change font weight). |
<MDBSelect selectAllClassName="customClass" > |
selectAllLabel |
String | "Select All" |
Sets text for Select All button. |
<MDBSelect selectAllLabel="Select All" > |
selectAllValue |
String | "0" |
Sets value for Select All button. |
<MDBSelect selectAllValue="0" > |
focusBackgroundColor |
String | "#eee" |
Sets background-color for focused option. |
<MDBSelect focusBackgroundColor="#eee" > |
focusShadow |
String | "inset 0px -17px 15px -16px rgba(0, 0, 0, 0.35)" |
Sets box-shadow for focused option. |
<MDBSelect focusShadow="inset 0px -17px 15px -16px rgba(0, 0, 0, 0.35)" >
|
API Reference: Select Methods
Name | Parameters | Description | Example |
---|---|---|---|
getTextContent |
Returns input text content. Use this method to get string with selected options. | <MDBSelect getTextContent={this.handleSelectChange} > |
|
getValue |
Returns Select value. Use this method to get array with selected options. | <MDBSelect getValue={this.handleSelectChange} > |
API Reference: SelectInput Properties
The table below shows the configuration options of the MDBSelectInput component.
Name | Type | Default | Description | Example |
---|---|---|---|---|
className |
String |
|
Sets custom classes. | <MDBSelectInput className="customClass" > |
selected |
String |
|
Works only with Select with markup! Set default select text content. |
<MDBSelect selected="Choose option" > |
API Reference: SelectOptions Properties
The table below shows the configuration options of the MDBSelectOptions component.
Name | Type | Default | Description | Example |
---|---|---|---|---|
className |
String |
|
Sets custom classes. | <MDBSelectOptions className="customClass" > |
search |
Boolean | false |
Search element will appear as the firs child of select. | <MDBSelectOptions search > |
searchLabel |
String | Search |
Changes default label of additional search element. | <MDBSelectOptions searchLabel="Find option" /> |
searchId |
String | selectSearchInput |
Changes default id of additional search element. | <MDBSelectOptions searchId="id" /> |
API Reference: SelectOption Properties
The table below shows the configuration options of the MDBSelectOption component.
Name | Type | Default | Description | Example |
---|---|---|---|---|
checked |
Boolean | false |
If true - the option will be preselected during mount. | <MDBSelectOption checked > |
className |
String |
|
Sets custom classes. | <MDBSelectOption className="customClass" > |
disabled |
Boolean | false |
If true - the option wont be clickable. | <MDBSelectOption disabled > |
separator |
Boolean | false |
If true - adds top border (sets disabled to true). | <MDBSelectOption separator > |
icon |
String |
|
Inserts icon into select option. | <MDBSelectOption icon="icon_url" > |
value |
String |
|
Sets option value (you can still use text content - value will be readable in getValue method). | <MDBSelectOption value="option 1" > |
API Reference: Options Array Structure
The table below shows the configuration options as an list of objects for alternative Select.
Name | Type | Default | Description | Example |
---|---|---|---|---|
checked |
Boolean |
|
If true - the option will be preselected during mount. | { checked: true } |
disabled |
Boolean |
|
If true - the option wont be clickable. | { disabled: true } |
icon |
String |
|
Inserts icon into select option. | { icon="icon_url" } |
text |
String |
|
Sets option text content. | { text: "Option one" } |
value |
String |
|
Sets option value. | { value: "1" } |