<ot-dropdown>. Use popovertarget on the trigger button and popover on the target element. Menu items should use role="menuitem" for proper accessibility.
Menu Dropdown
Popover Dropdown
<ot-dropdown> can also be used to show popover content like confirmation dialogs:
Features
Auto-positioning
Automatically positions dropdown to stay within viewport bounds, flipping if needed
Keyboard Navigation
Arrow up/down to navigate menu items, Enter to select, Escape to close
ARIA Support
Manages
aria-expanded state and menu item roles for screen readersNative Popover API
Uses the native Popover API for better performance and accessibility
How It Works
HTML Attributes
popovertarget="menu-id"- Add to trigger button, links to popover by IDpopover- Add to menu/content elementid="menu-id"- Add to popover element, must match popovertargetrole="menuitem"- Add to each menu item button for accessibility
Web Component
The<ot-dropdown> web component provides:
- Automatic positioning - Calculates trigger position and positions popover accordingly
- Viewport awareness - Flips popover position if it would overflow the viewport
- Scroll handling - Updates position on scroll to keep popover aligned
- Keyboard navigation - Arrow keys navigate menu items, wrapping at edges
- Focus management - Auto-focuses first item on open, returns focus to trigger on close
- ARIA state - Sets
aria-expandedon trigger based on open/closed state
Styling Details
Popover Container
Popover Container
- Position: fixed (relative to viewport)
- Min width: 12rem
- Background:
var(--background) - Border: 1px solid
var(--border) - Border radius:
var(--radius-medium) - Box shadow:
var(--shadow-medium) - Smooth opacity and transform transitions (150ms)
Menu Items
Menu Items
Animations
Animations
- Entry: fades in and slides down 4px
- Exit: fades out and slides up 4px
- Duration: 150ms with ease-out timing
- Uses
@starting-stylefor smooth entry animations
Keyboard Navigation
Move focus to next menu item (wraps to first)
Move focus to previous menu item (wraps to last)
Activate focused menu item
Close dropdown and return focus to trigger
Close dropdown (native popover behavior)
Accessibility
- Uses native Popover API for proper modal behavior
role="menuitem"on menu items for screen reader supportaria-expandedattribute automatically managed on trigger- Focus trapped within menu when open
- Focus returns to trigger when closed
- Keyboard navigation with arrow keys
- ESC key closes dropdown
JavaScript API
The<ot-dropdown> component extends OtBase and provides:
/home/daytona/workspace/source/src/js/dropdown.js:1-75
Browser Support
Requires support for:- Native Popover API
- CSS
@starting-style light-dark()color function- Custom elements (web components)
CSS Variables
--background- Popover background--border- Border color--radius-medium,--radius-small- Border radius values--shadow-medium- Box shadow--space-1,--space-2,--space-3- Spacing--text-7- Font size--foreground- Text color--accent- Hover/focus background