DropDown

DropDown

Dropdown is a toggleable menu embedding additional links or content. It allows you to construct advanced navigation and link categorization.

In case of more complicated navigations systems dropdowns are the essential elements providing you with possibility of placing all the most relevant links in our navigation bar (or other component acting as navigation - such as SideNav)

Aside from being not only highly functional, CDB dropdowns are also extraordinary visually attractive. It gives them this characteristic Material Design effects, like shadows, living colors or charming waves effect after opening a link.

They’re toggled by clicking, not by hovering; this is an intentional design decision. Why?

CDB is "mobile first" framework so, we avoid mixing functional elements and interaction by hovering because it decreases User Experience of users of mobile devices.

Basic DropDown

Dark Toggle Bar

html
<CDBDropDown>
<CDBDropDownToggle color="dark" (click)="menu1.toggleDropdown($event)"
(mouseenter)="menu1.toggleDropdown($event)">
Dark Toggle Bar
</CDBDropDownToggle>
<CDBDropDownMenu #menu1="cdbDropdownMenu">
This is the toggle menu
</CDBDropDownMenu>
</CDBDropDown>

Primary Toggler with Caret

html
<CDBDropDown>
<CDBDropDownToggle color="primary" [caretDropDown]=true (click)="menu2.toggleDropdown($event)">
Primary Toggle Bar
</CDBDropDownToggle>
<CDBDropDownMenu #menu2="cdbDropdownMenu" placement="bottom">
This is the toogle menu with caret
</CDBDropDownMenu>
</CDBDropDown>

Secondary Toggle Bar

html
<CDBDropDown>
<CDBDropDownToggle [nav]=true color="secondary" [caretDropRight]=true
(click)="menu3.toggleDropdown($event)">
Secondary Toggle Bar as nav
</CDBDropDownToggle>
<CDBDropDownMenu #menu3="cdbDropdownMenu" placement="right">
This is the toogle menu to the right
</CDBDropDownMenu>
</CDBDropDown>

Danger Toggle Bar

html
<CDBDropDown>
<CDBDropDownToggle color="danger" [caretDropUp]=true (click)="menu4.toggleDropdown($event)">
Danger Toggle Bar
</CDBDropDownToggle>
<CDBDropDownMenu #menu4="cdbDropdownMenu" placement="top">
This is the toogle menu to the top
</CDBDropDownMenu>
</CDBDropDown>

Success Toggle Bar

html
<CDBDropDown>
<CDBDropDownToggle color="success" [caretDropLeft]=true (click)="menu5.toggleDropdown($event)">
Success Toggle Bar
</CDBDropDownToggle>
<CDBDropDownMenu #menu5="cdbDropdownMenu" placement="left">
This is the toogle menu to the bottom
</CDBDropDownMenu>
</CDBDropDown>

Large DropDown

html
<CDBDropDown>
<CDBDropDownToggle color="dark" size="lg" (click)="menu6.toggleDropdown($event)">
Large Dark Toggle Bar
</CDBDropDownToggle>
<CDBDropDownMenu #menu6="cdbDropdownMenu" placement="right">
This is the toogle menu to the right
</CDBDropDownMenu>
</CDBDropDown>

Small Dropdown

html
<CDBDropDown>
<CDBDropDownToggle color="secondary" size="sm" (click)="menu7.toggleDropdown($event)">
Small Secondary Toggle Bar
</CDBDropDownToggle>
<CDBDropDownMenu #menu7="cdbDropdownMenu" placement="right">
<CDBDropDownItem [header]=true>cold place</CDBDropDownItem>
<CDBDropDownItem [divider]=true></CDBDropDownItem>
<CDBDropDownItem [disabled]=true>
First Item in cold place
</CDBDropDownItem>
<CDBDropDownItem [disabled]=true>second</CDBDropDownItem>
<CDBDropDownItem [toggle]=true>second</CDBDropDownItem>
<CDBDropDownItem>second</CDBDropDownItem>
<CDBDropDownItem>
<CDBLink to="/alert"> Alert</CDBLink>
</CDBDropDownItem>
</CDBDropDownMenu>
</CDBDropDown>

Disabled Danger Toggle Bar

html
<CDBDropDown>
<CDBDropDownToggle color="danger" [disabled]=true (click)="menu8.toggleDropdown($event)">
Disabled Danger Toggle Bar
</CDBDropDownToggle>
<CDBDropDownMenu #menu8="cdbDropdownMenu" placement="right">
This is the toogle menu to the right
</CDBDropDownMenu>
</CDBDropDown>
html
<CDBDropDown>
<CDBDropDownToggle color="secondary" (click)="menu9.toggleDropdown($event)">
DropDown
</CDBDropDownToggle>
<CDBDropDownMenu #menu9="cdbDropdownMenu" placement="right">
<CDBDropDownItem [header]=true>Cold place</CDBDropDownItem>
<CDBDropDownItem>
First Item in cold place
</CDBDropDownItem>
<CDBDropDownItem [toggle]=true>second</CDBDropDownItem>
<CDBDropDownItem>second</CDBDropDownItem>
</CDBDropDownMenu>
</CDBDropDown>
html
<CDBDropDown>
<CDBDropDownToggle color="warning" (click)="menu10.toggleDropdown($event)">
DropDown
</CDBDropDownToggle>
<CDBDropDownMenu #menu10="cdbDropdownMenu" placement="left">
<CDBDropDownItem>
<CDBLink to="/alert">Alert</CDBLink>
</CDBDropDownItem>
<CDBDropDownItem [divider]=true></CDBDropDownItem>
<CDBDropDownItem>
First Item in cold place
</CDBDropDownItem>
<CDBDropDownItem [toggle]=true>second</CDBDropDownItem>
<CDBDropDownItem>second</CDBDropDownItem>
</CDBDropDownMenu>
</CDBDropDown>

Disable Menu Items

html
<CDBDropDown>
<CDBDropDownToggle color="success" (click)="menu11.toggleDropdown($event)">
DropDown
</CDBDropDownToggle>
<CDBDropDownMenu #menu11="cdbDropdownMenu" placement="top">
<CDBDropDownItem>Cold place</CDBDropDownItem>
<CDBDropDownItem [disabled]=true>
Disabled
</CDBDropDownItem>
<CDBDropDownItem [disabled]=true>Second</CDBDropDownItem>
<CDBDropDownItem>Last</CDBDropDownItem>
</CDBDropDownMenu>
</CDBDropDown>

Active Menu Items

html
<CDBDropDown>
<CDBDropDownToggle color="dark" (click)="menu12.toggleDropdown($event)">
DropDown
</CDBDropDownToggle>
<CDBDropDownMenu #menu12="cdbDropdownMenu" placement="top">
<CDBDropDownItem>Cold place</CDBDropDownItem>
<CDBDropDownItem [active]=true>
Active
</CDBDropDownItem>
<CDBDropDownItem [toggle]=true>Second</CDBDropDownItem>
<CDBDropDownItem>Last</CDBDropDownItem>
</CDBDropDownMenu>
</CDBDropDown>

API

Here in this section you will find information about required modules and available inputs, outputs, methods and events of this component.

Contrast Dropdown Bootstrap Modules used

import {DropdownModule } from 'cdb';

API Reference: Contrast Dropdown Bootstrap Inputs

The table below shows the possible input of the Dropdown component.

NameTypeDefaultDescriptionExample
classStringAdds custom classesclass="myClass"
dropupBooleanfalseTrigger dropdown menu above dropdown buttondropUp
dropleftBooleanfalseTrigger dropdown menu on the left side of dropdown buttondropleft
droprightBooleanfalseTrigger dropdown menu on the right side of dropdown buttondropright
togglefunctionControl dropdown on clicktoggle={handleToggle}

API Reference: Contrast DropDownItem Properties

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

NameTypeDefaultDescriptionExample
classStringAdds custom classesclass="myClass"
activeBooleanfalseSets active state for of the menu itemactive=true
disableBooleanfalseDisables item and sets its color to light greydisable
dividerBooleanfalsePlaces dividing line instead of contentdivider
headerBooleanfalseFormats the item as a menu header (grey text, more padding)header
toggleBooleanfalseSet to false to prevent from closing Dropdown on clicktoggle=false
onClickfunctionToggle dropdown on clickonClick={handleToggle}

API Reference: Contrast DropDownMenu Properties

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

NameTypeDefaultDescriptionExample
classStringAdds custom classesclass="myClass"
colorStringprimaryChanges DropdownMenuItem hover background color, accepts ["primary", "secondary", "success", "dark", "danger", "info", "warning"]color="secondary"
disableBooleanfalseDisables item and sets its color to light greydisable=true
dividerBooleanfalsePlaces dividing line instead of contentdivider=true
headerBooleanfalseFormats the item as a menu header (grey text, more padding)header=true
toggleBooleanfalseSet to false to prevent from closing Dropdown on clicktoggle=false
onClickfunctionToggle dropdown on clickonClick={handleToggle}
dropupBooleanfalseTrigger dropdown menu above dropdown buttondropup=true
dropdownBooleanfalseTrigger dropdown menu below dropdown buttondropdown=true
dropleftBooleanfalseTrigger dropdown menu on the left side of dropdown buttondropleft=true
droprightBooleanfalseTrigger dropdown menu on the right side of dropdown buttondropright=true

API Reference: Contrast DropDownToggle Properties

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

NameTypeDefaultDescriptionExample
classStringAdds custom classesclass="myClass"
colorStringprimaryChanges DropdownMenuItem hover background color, accepts ["primary", "secondary", "success", "dark", "danger", "info", "warning"]color="secondary"
sizeStringDetermines size of the Dropdown button, available parameters: ["lg", "sm"] (medium by default)size="sm"
caretBooleanfalseInserts caret icon inside Dropdown buttoncaret=true
navBooleanfalseProps required while using Dropdown within Navbarnav=true
dropupBooleanfalseTrigger dropdown menu above dropdown buttondropup=true
dropdownBooleanfalseTrigger dropdown menu below dropdown buttondropdown=true
dropleftBooleanfalseTrigger dropdown menu on the left side of dropdown buttondropleft=true
droprightBooleanfalseTrigger dropdown menu on the right side of dropdown buttondropright=true