Dropdowns & Popovers

Contextual overlays for menus, options, and additional content.

Dropdowns

Toggleable contextual overlays for displaying lists of links and actions.

Basic Dropdown

Dropdown Alignment

Left & Right Aligned

Dropdown with Dividers

Grouped Items

Dropdown Headers

With Section Headers

Popovers

Small overlays that provide contextual information or actions.

Basic Popover

Popover Title

This is popover content with more detailed information.

Popover Positions

Positioning

Popover on top

Popover on bottom

Popover on left

Popover on right

Common Patterns

User Menu

Profile Dropdown

Actions Menu

Context Menu

Project Document

Updated 2 hours ago

Notification Popover

Rich Popover Content

Notifications

New comment on your post

2 minutes ago

Team invitation

1 hour ago

Your report is ready

3 hours ago

JavaScript Implementation

Basic Toggle Script

Add this JavaScript to enable dropdown and popover functionality:

Toggle Implementation

// Dropdown toggle
document.querySelectorAll('.dropdown > button').forEach(button => {
  button.addEventListener('click', (e) => {
    e.stopPropagation()
    const dropdown = button.parentElement

    // Close other open dropdowns
    document.querySelectorAll('.dropdown.open').forEach(d => {
      if (d !== dropdown) d.classList.remove('open')
    })

    dropdown.classList.toggle('open')
  })
})

// Popover toggle
document.querySelectorAll('.popover-container > button').forEach(button => {
  button.addEventListener('click', (e) => {
    e.stopPropagation()
    const container = button.parentElement

    // Close other open popovers
    document.querySelectorAll('.popover-container.open').forEach(c => {
      if (c !== container) c.classList.remove('open')
    })

    container.classList.toggle('open')
  })
})

// Close on outside click
document.addEventListener('click', () => {
  document.querySelectorAll('.dropdown.open, .popover-container.open').forEach(el => {
    el.classList.remove('open')
  })
})

// Close on escape key
document.addEventListener('keydown', (e) => {
  if (e.key === 'Escape') {
    document.querySelectorAll('.dropdown.open, .popover-container.open').forEach(el => {
      el.classList.remove('open')
    })
  }
})

Accessibility

Best Practices:
  • Use role="menu" on dropdown menus with role="menuitem" on items
  • Add aria-haspopup="true" and aria-expanded to trigger buttons
  • Ensure keyboard navigation (Arrow keys, Enter, Escape)
  • Trap focus within open dropdowns and popovers
  • Return focus to trigger button when closing
  • Use aria-labelledby to associate popovers with their triggers
  • Ensure sufficient color contrast for dropdown items
  • Make clickable areas at least 44×44 pixels