DOCS
v0.4

Components / Dropdown

Dropdown

Floating dropdown menu with scale+fade entrance/exit animations, staggered item reveal, full keyboard navigation (arrows/home/end/escape), click-outside close, cg-icon integration, keyboard shortcuts, and divider support.

actionsv0.5.0

Playground

Examples

With icons + shortcuts
Edit
<cg-dropdown open><cg-button slot="trigger">Edit</cg-button></cg-dropdown>
File menu
File
<cg-dropdown open><cg-button slot="trigger" variant="secondary">File</cg-button></cg-dropdown>
Account menu
Account
<cg-dropdown open><cg-button slot="trigger" variant="tertiary">Account</cg-button></cg-dropdown>
Overflow (3 dots)
<div style="display:flex;justify-content:flex-end;"><cg-dropdown position="bottom-end" open><cg-button slot="trigger" variant="secondary" size="sm"></cg-button></cg-dropdown></div>

Import

import { CgDropdown } from '@cognivo/components';
// Or tree-shake: import '@cognivo/components/cg-dropdown';

Per-component imports ship only that component (~8 kB gzip).

API Reference

PropTypeDefaultDescription
openbooleanfalseOpen state
position"bottom-start" | "bottom-end" | "top-start" | "top-end""bottom-start"Menu position relative to trigger
loadingbooleanfalseShow loading spinner instead of items
rounded"none" | "sm" | "md" | "lg""lg"Border radius variant
_trigger"button-arrow" | "dots-vertical" | "dots-horizontal" | "button-plain""button-arrow"Trigger style (playground only)
_itemStyle"with-icons" | "with-shortcuts" | "icons-shortcuts" | "plain""icons-shortcuts"Item display (playground only)

Events

EventDetailDescription
cg-dropdown-open{}Menu opened
cg-dropdown-close{}Menu closed
cg-dropdown-select{id: string, label: string}Item selected