CoreUI Angular Logo
Framework:
  • JavaScript / Vanilla JS
  • React.js
  • Vue.js
Getting startedIntroductionSupport CoreUICustomizeSassOptionsCSS VariablesLayoutBreakpointsContainersGridColumnsGuttersFormsOverviewDate PickerPRODate Range PickerPROForm ControlSelectMulti SelectPROChecks & RadiosPassword InputPRORangeRange SliderPRORatingPROStepperPROInput GroupFloating LabelsLayoutTime PickerPROValidationComponentsAccordionAlertAvatarBadgeBreadcrumbButtonButton GroupCalendarPROCalloutCardCarouselClose buttonCollapseDropdownFooterHeaderImageList GroupLoading ButtonPROModalNavNavbarOffcanvasPaginationPlaceholderPopoverProgressSmart PaginationPROSmart TablePROSidebarSpinnerTableTabsNewToastTooltipWidgetsIconsChartsTemplatesNewAdmin & DasardDownloadInstallationCustomizeContentMigrationv4 → v5v3 → v4Angular version


DownloadHire UsGet CoreUI PRO
On this page

    Angular Dropdown Component

    Angular Dropdown component allows you to toggle contextual overlays for displaying lists, links, and more html elements.

    Overview

    Dropdowns are toggleable, contextual overlays for displaying lists of links and more.

    Dropdowns are built on a third party library, Popper.js, which provides dynamic positioning and viewport detection. Popper.js isn't used to position dropdowns in navbars though as dynamic positioning isn't required.

    Examples

    Bind the dropdown toggle and the dropdown menu inside c-dropdown, or different element that declares position: relative;. Dropdowns can be triggered from a or button elements to better fit your possible requirements.

    Single button

    Here's how you can put them to work with either button elements:

    • Action
    • Another action
    • Something else here
    Loading...
    import { Component } from '@angular/core';
    import { RouterLink } from '@angular/router';
    import {
      ButtonDirective,
      DropdownComponent,
      DropdownItemDirective,
      DropdownMenuDirective,
      DropdownToggleDirective
    } from '@coreui/angular';
    
    @Component({
      selector: 'docs-dropdown01',
      templateUrl: './dropdown01.component.html',
      standalone: true,
      imports: [
        DropdownComponent,
        ButtonDirective,
        DropdownToggleDirective,
        DropdownMenuDirective,
        DropdownItemDirective,
        RouterLink
      ]
    })
    export class Dropdown01Component {}
    

    And with a elements:

    Dropdown button
    • Action
    • Another action
    • Something else here
    Loading...
    import { Component } from '@angular/core';
    import { RouterLink } from '@angular/router';
    import {
      ButtonDirective,
      DropdownComponent,
      DropdownItemDirective,
      DropdownMenuDirective,
      DropdownToggleDirective
    } from '@coreui/angular';
    
    @Component({
      selector: 'docs-dropdown02',
      templateUrl: './dropdown02.component.html',
      standalone: true,
      imports: [
        DropdownComponent,
        ButtonDirective,
        DropdownToggleDirective,
        RouterLink,
        DropdownMenuDirective,
        DropdownItemDirective
      ]
    })
    export class Dropdown02Component {}
    

    The best part is you can do this with any button variant, too:

    Loading...
    import { Component } from '@angular/core';
    import { RouterLink } from '@angular/router';
    import {
      ButtonDirective,
      DropdownComponent,
      DropdownItemDirective,
      DropdownMenuDirective,
      DropdownToggleDirective
    } from '@coreui/angular';
    
    @Component({
      selector: 'docs-dropdown03',
      templateUrl: './dropdown03.component.html',
      standalone: true,
      imports: [
        DropdownComponent,
        ButtonDirective,
        DropdownToggleDirective,
        DropdownMenuDirective,
        DropdownItemDirective,
        RouterLink
      ]
    })
    export class Dropdown03Component {
      public colors = ['primary', 'secondary', 'success', 'info', 'warning', 'danger'];
    }
    

    Split button

    Similarly, create split button dropdowns with virtually the same markup as single button dropdowns, but with the addition of boolean prop split for proper spacing around the dropdown caret.

    We use this extra class to reduce the horizontal padding on either side of the caret by 25% and remove the margin-left that's attached for normal button dropdowns. Those additional changes hold the caret centered in the split button and implement a more properly sized hit area next to the main button.

    Loading...
    import { Component } from '@angular/core';
    import { RouterLink } from '@angular/router';
    import {
      ButtonDirective,
      DropdownComponent,
      DropdownItemDirective,
      DropdownMenuDirective,
      DropdownToggleDirective
    } from '@coreui/angular';
    
    @Component({
      selector: 'docs-dropdown04',
      templateUrl: './dropdown04.component.html',
      standalone: true,
      imports: [
        DropdownComponent,
        ButtonDirective,
        DropdownToggleDirective,
        DropdownMenuDirective,
        DropdownItemDirective,
        RouterLink
      ]
    })
    export class Dropdown04Component {
      public colors = ['primary', 'secondary', 'success', 'info', 'warning', 'danger'];
    }
    

    Sizing

    Button dropdowns work with buttons of all sizes, including default and split dropdown buttons.

    Loading...
    Loading...
    Loading...
    Loading...

    Dark dropdowns

    Opt into darker dropdowns to match a dark navbar or custom style by set dark property. No changes are required to the dropdown items.

    Loading...
    import { Component } from '@angular/core';
    import {
      ButtonDirective,
      DropdownComponent,
      DropdownItemDirective,
      DropdownMenuDirective,
      DropdownToggleDirective
    } from '@coreui/angular';
    
    @Component({
      selector: 'docs-dropdown07',
      templateUrl: './dropdown07.component.html',
      standalone: true,
      imports: [DropdownComponent, ButtonDirective, DropdownToggleDirective, DropdownMenuDirective, DropdownItemDirective]
    })
    export class Dropdown07Component {}
    

    And putting it to use in a navbar:

    Navbar
    Dropdown
    Loading...
    import { Component } from '@angular/core';
    import {
      CollapseDirective,
      ContainerComponent,
      DropdownComponent,
      DropdownItemDirective,
      DropdownMenuDirective,
      DropdownToggleDirective,
      NavbarBrandDirective,
      NavbarComponent,
      NavbarNavComponent,
      NavbarTogglerDirective,
      NavItemComponent,
      NavLinkDirective
    } from '@coreui/angular';
    
    @Component({
      selector: 'docs-dropdown08',
      templateUrl: './dropdown08.component.html',
      standalone: true,
      imports: [
        NavbarComponent,
        ContainerComponent,
        NavbarBrandDirective,
        NavbarTogglerDirective,
        CollapseDirective,
        NavbarNavComponent,
        NavItemComponent,
        DropdownComponent,
        DropdownToggleDirective,
        NavLinkDirective,
        DropdownMenuDirective,
        DropdownItemDirective
      ]
    })
    export class Dropdown08Component {}
    

    Directions

    RTL

    Directions are mirrored when using CoreUI in RTL, meaning dropstart will appear on the right side.

    Centered

    Trigger dropdown menus centered below the toggle by adding direction="center" to the c-dropdown component.

    Loading...
    import { Component } from '@angular/core';
    import {
      ButtonDirective,
      DropdownComponent,
      DropdownItemDirective,
      DropdownMenuDirective,
      DropdownToggleDirective
    } from '@coreui/angular';
    
    @Component({
      selector: 'docs-dropdown21',
      templateUrl: './dropdown21.component.html',
      standalone: true,
      imports: [DropdownComponent, ButtonDirective, DropdownToggleDirective, DropdownMenuDirective, DropdownItemDirective]
    })
    export class Dropdown21Component {}
    

    Dropup

    Trigger dropdown menus above elements by adding direction="dropup" to the c-dropdown component.

    Loading...
    import { Component } from '@angular/core';
    import {
      ButtonDirective,
      DropdownComponent,
      DropdownItemDirective,
      DropdownMenuDirective,
      DropdownToggleDirective
    } from '@coreui/angular';
    
    @Component({
      selector: 'docs-dropdown09',
      templateUrl: './dropdown09.component.html',
      standalone: true,
      imports: [DropdownComponent, ButtonDirective, DropdownToggleDirective, DropdownMenuDirective, DropdownItemDirective]
    })
    export class Dropdown09Component {}
    

    Dropup Centered

    Trigger dropup menu centered above the toggle by adding direction="dropup-center" to the c-dropdowncomponent.

    Loading...
    import { Component } from '@angular/core';
    import {
      ButtonDirective,
      DropdownComponent,
      DropdownItemDirective,
      DropdownMenuDirective,
      DropdownToggleDirective
    } from '@coreui/angular';
    
    @Component({
      selector: 'docs-dropdown22',
      templateUrl: './dropdown22.component.html',
      standalone: true,
      imports: [DropdownComponent, ButtonDirective, DropdownToggleDirective, DropdownMenuDirective, DropdownItemDirective]
    })
    export class Dropdown22Component {}
    

    Dropright

    Trigger dropdown menus at the right of the elements by adding direction="dropend" to the c-dropdowncomponent.

    Loading...
    import { Component } from '@angular/core';
    import {
      ButtonDirective,
      DropdownComponent,
      DropdownItemDirective,
      DropdownMenuDirective,
      DropdownToggleDirective
    } from '@coreui/angular';
    
    @Component({
      selector: 'docs-dropdown10',
      templateUrl: './dropdown10.component.html',
      standalone: true,
      imports: [DropdownComponent, ButtonDirective, DropdownToggleDirective, DropdownMenuDirective, DropdownItemDirective]
    })
    export class Dropdown10Component {}
    

    Dropleft

    Trigger dropdown menus at the left of the elements by adding direction="dropstart" to the c-dropdowncomponent.

    Loading...
    Loading...

    Menu items

    Historically dropdown menu contents had to be links, but that's no longer the case with v4. Now you can optionally use button elements in your dropdowns instead of just a.

    Loading...
    import { Component } from '@angular/core';
    import {
      ButtonDirective,
      DropdownComponent,
      DropdownItemDirective,
      DropdownMenuDirective,
      DropdownToggleDirective
    } from '@coreui/angular';
    
    @Component({
      selector: 'docs-dropdown12',
      templateUrl: './dropdown12.component.html',
      standalone: true,
      imports: [DropdownComponent, ButtonDirective, DropdownToggleDirective, DropdownMenuDirective, DropdownItemDirective]
    })
    export class Dropdown12Component {}
    

    You can also create non-interactive dropdown items with cDropdownItemText.

    Dropdown item text
    Loading...
    import { Component } from '@angular/core';
    import { DropdownItemDirective, DropdownItemPlainDirective } from '@coreui/angular';
    
    @Component({
      selector: 'docs-dropdown15',
      templateUrl: './dropdown15.component.html',
      standalone: true,
      imports: [DropdownItemPlainDirective, DropdownItemDirective],
      styles: `
        :host {
          .dropdown-menu {
            display: block;
            position: static;
          }
        }
      `
    })
    export class Dropdown15Component {}
    

    Active

    Set boolean property active to style item as active.

    Loading...
    import { Component } from '@angular/core';
    import { DropdownItemDirective } from '@coreui/angular';
    
    @Component({
      selector: 'docs-dropdown16',
      templateUrl: './dropdown16.component.html',
      standalone: true,
      imports: [DropdownItemDirective],
      styles: `
        :host {
          .dropdown-menu {
            display: block;
            position: static;
          }
        }
      `
    })
    export class Dropdown16Component {}
    

    Disabled

    Add disabled boolean property to items in the dropdown to style them as disabled.

    Loading...
    Loading...

    Menu alignment

    By default, a dropdown menu is automatically positioned 100% from the top and along the left side of its parent. Add aligment="end" to right align the dropdown menu.

    Heads up! Dropdowns are positioned thanks to Popper.js.

    Loading...
    Loading...

    Menu content

    Headers

    Add a header to label sections of actions in any dropdown menu.

    In the following example we use div without cDropdownMenu to show dropdown menu content.

    Header
    ActionAnother action
    Loading...
    Loading...

    Dividers

    Separate groups of related menu items with a divider.

    In the following example we use div without cDropdownMenu to show dropdown menu content.

    • Action
    • Another action
    • Something else here

    Loading...
    Loading...

    Text

    Place any freeform text within a dropdown menu with text. Note that you'll likely need additional sizing styles to constrain the menu width.

    Some example text that's free-flowing within the dropdown menu.

    And this is more example text.

    Loading...
    Loading...

    Forms

    Put a form within a dropdown menu, or make it into a dropdown menu.

    Loading...
    Loading...

    API reference

    Dropdown Module

    import { DropdownModule } from '@coreui/angular';
    
    @NgModule({
       imports: [DropdownModule,]
    })
    export class AppModule() { }
    

    c-dropdown

    component

    Inputs
    namedescriptiontypedefault
    alignmentSet alignment of dropdown menu.stringundefined
    darkSets a darker color scheme to match a dark navbar.booleanfalse
    directionSets a specified direction and location of the dropdown menu.center | dropup | 'dropup-center' | dropend | dropstartundefined
    placementDescribes the placement of your component after Popper.js has applied all the modifiers that may have flipped or altered the originally provided placement property.Placementsbottom-start
    popperIf you want to disable dynamic positioning set this property to false.booleantrue
    variantSet the dropdown variant to an btn-group, dropdown, input-group, and nav-item.btn-group | dropdown | input-group | nav-itemdropdown
    visibleToggle the visibility of dropdown menu component.booleanfalse
    autoClose

    Configure the auto close behavior of the dropdown:

    • true - the dropdown will be closed by clicking outside or inside the dropdown menu.
    • false - the dropdown will be closed by clicking the toggle button and manually calling hide or toggle method. (Also will not be closed by pressing esc key)
    • inside - the dropdown will be closed (only) by clicking inside the dropdown menu.
    • outside - the dropdown will be closed (only) by clicking outside the dropdown menu.
    boolean | stringtrue
    popperConfigTo change dropdown default Popper config, see Popper configurationOptionsdefault
    Outputs
    namedescriptiontype
    visibleChangeEvent emitted on visible change.boolean

    cDropdownClose

    directive

    Inputs
    namedescriptiontypedefault
    disabledToggle the disabled state for the cDropdownClose host element.booleanundefined

    cDropdownDivider

    directive

    cDropdownHeader

    directive

    cDropdownItem

    directive

    Inputs
    namedescriptiontypedefault
    activeToggle the active state for the dropdown item.booleanundefined
    autoCloseClose dropdown menu on cDropdownItem click.booleantrue
    disabledToggle the disabled state for the dropdown item.booleanundefined

    cDropdownItemPlain

    directive

    cDropdownMenu

    directive

    Inputs
    namedescriptiontypedefault
    darkSets a darker color scheme to match a dark navbar.booleantrue

    cDropdownToggle

    directive

    Inputs
    namedescriptiontypedefault
    caretEnables pseudo element caret on toggler.booleantrue
    splitCreate split button dropdowns.booleanundefined
    • Twitter
    • Support
    • CoreUI (Vanilla)
    • CoreUI for React.js
    • CoreUI for Vue.js

    CoreUI for Angular is Open Source UI Components Library for Angular.

    Currently v5.5.2 Code licensed MIT , docs CC BY 3.0 .
    CoreUI PRO requires a commercial license.