🤩
Windframe Import Update is finally here.

Select 2

Angular Bootstrap Select2

The Angular Bootstrap Select2 is the pro version of the Contrast Angular Bootstrap Select component, CDBSelect. With more predefined styles for your select button. Get the CDB pro version to use in your project.

Importing the Contrast Angular Bootstrap Select2 Module

To use the Contrast Angular Bootstrap Select2 component in your project you need to import Select2Module.

typescript
import {Select2Module } from 'cdbangular';

Select Button

Angular Bootstrap Select

html
html
<CDBSelect2 [options]='select2Options' [iconBrand]=true selected="Choose an option" color="white"></CDBSelect2>
typescript
typescript
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-select2',
templateUrl: './select2.component.html',
styleUrls: ['./select2.component.scss'],
})
export class Select2Component implements OnInit {
select2Options = [
{
text: 'Select Option',
icon: 'stack-overflow',
},
{
text: 'Another Option',
icon: 'reddit',
},
{
text: 'Option 3',
icon: 'instagram',
},
{
text: 'Option 4',
},
{
text: 'Last Option',
},
];
constructor() {}
ngOnInit(): void {}
}

Disable Select Button

Use the disabled prop to disable the select button.

Angular Bootstrap Select Disabled

html
html
<CDBSelect2 [options]='select2Options' [iconBrand]=true selected="Choose an option" [disabled]=true color="none"></CDBSelect2>
typescript
typescript
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-select2',
templateUrl: './select2.component.html',
styleUrls: ['./select2.component.scss'],
})
export class Select2Component implements OnInit {
select2Options = [
{
text: 'Select Option',
icon: 'stack-overflow',
},
{
text: 'Another Option',
icon: 'reddit',
},
{
text: 'Option 3',
icon: 'instagram',
},
{
text: 'Option 4',
},
{
text: 'Last Option',
},
];
constructor() {}
ngOnInit(): void {}
}

Colored Select Button

Use the color prop to give the select button a background color of your choice.

Angular Bootstrap Select Colored

html
html
<CDBSelect2 [options]='select2Options' [iconBrand]=true selected="Choose an option" color="primary"></CDBSelect2>
<CDBSelect2 [options]='select2Options' [iconBrand]=true selected="Choose an option" color="secondary"></CDBSelect2>
<CDBSelect2 [options]='select2Options' [iconBrand]=true selected="Choose an option" color="success"></CDBSelect2>
<CDBSelect2 [options]='select2Options' [iconBrand]=true selected="Choose an option" color="warning"></CDBSelect2>
<CDBSelect2 [options]='select2Options' [iconBrand]=true selected="Choose an option" color="dark"></CDBSelect2>
typescript
typescript
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-select2',
templateUrl: './select2.component.html',
styleUrls: ['./select2.component.scss'],
})
export class Select2Component implements OnInit {
select2Options = [
{
text: 'Select Option',
icon: 'stack-overflow',
},
{
text: 'Another Option',
icon: 'reddit',
},
{
text: 'Option 3',
icon: 'instagram',
},
{
text: 'Option 4',
},
{
text: 'Last Option',
},
];
constructor() {}
ngOnInit(): void {}
}

Colored Options with Hover

The hoverColor prop gives your select options an hover effect.

Angular Bootstrap Select Hover Color

html
html
<CDBSelect2 [options]='select2Options' [iconBrand]=true selected="Choose an option" [hoverColor]=true color="danger"></CDBSelect2>
typescript
typescript
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-select2',
templateUrl: './select2.component.html',
styleUrls: ['./select2.component.scss'],
})
export class Select2Component implements OnInit {
select2Options = [
{
text: 'Select Option',
icon: 'stack-overflow',
},
{
text: 'Another Option',
icon: 'reddit',
},
{
text: 'Option 3',
icon: 'instagram',
},
{
text: 'Option 4',
},
{
text: 'Last Option',
},
];
constructor() {}
ngOnInit(): void {}
}

API Reference: Contrast Angular Bootstrap Select2 Props

This section will build on your information about the props you get to use with the Contrast Angular Bootstrap Select2 component. You will find out what these props do, their default values, and how you would use them in your code.

The table below lists other prop options of the CDBSelect2.

NameTypeDefaultDescriptionExample
classStringAdds custom classesclass="myClass"
disableBooleanfalseIf true - the option wont be clickable.disabled=true
colorStringSets colorful hover effect on select options.color="primary"
iconSizeStringSets size of icon brand in select optioniconSize="20px"
iconBrandBooleanfalseadds icon to the select optioniconBrand=true
iconLightBooleanfalseSets the icon lighticonLight=true
iconRegularBooleanfalseSets the icon regulariconRegular=true
iconClassStringAdds custom class to iconiconClass="myClass"
optionsArray of ObjectsSets options array as source of data. This property is used in alternative Select version.options=[options]
hoverColorBooleanfalseSets hover effect on select options.hoverColor=true
selectedStringSet default select text content.selected="Choose one"
optionClassNameStringAdds custom classes to optionsoptionClassName="my-class"

Trying to build out all user interfaces and components for your website or web app from scratch can become a very tedious task. A huge reason why we created Contrast Bootstrap to help 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 UI Kit featuring over 10000+ component variants. Together with a template of 5 admin dashboards and 23+ additional multipurpose pages template for building almost any type of website or web app. You can view a demo and learn more about Contrast by clicking here.Download the free react template

ad-banner

Contrast Bootstrap PRO was built using the most popular CSS framework Bootstrap to help build your next landing, admin SAAS, prelaunch etc project with a clean, prebuilt and well documented template and UI components.Learn more about Contrast