Dropdown extends Floater

Assign a floater panel to a MouseEvent

Example

JS
new Dropdown({
    content: createElement({
        class: 'bg-white pad',
        content: 'Hello World'
    }),
    anchor: '#hi-button'
})
HTML
<komp-dropdown anchor="#hi-button">
    Hello World
</komp-dropdown>

Constructor

new Dropdown(options)
options : Object optional
mouseevent : string optional

MouseEvent that toggles floater

removeOnBlur : boolean optional

Hide dropdown when user clicks outside or focuses elsewhere

timeout : number optional

Milliseconds to wait before hiding dropdown after mouseleave

content : string | HTMLElement | Array | Object optional

content for the floater, uses Dolla's content

anchor : HTMLElement

element to anchor positioning to

container : string | HTMLElement optional

element to append floater to. If String, then used as selector for this.closest(selector)

placement : string optional

how the floater is anchored, e.g. "top", "top-start", "top-end", "left", "left-start"...

strategy : string optional

how the floater is positioned in the document. "absolute" or "fixed"

flip : boolean | Object optional

See https://floating-ui.com/docs/flip, defaults to false in favor of autoPlacement

offset : boolean | Object optional
shift : boolean | Object optional
arrow : boolean | number optional

True to show default size, or number in pixels

size : boolean | Object optional
autoPlacement : boolean | Object optional
inline : boolean | Object optional
autoUpdate : boolean | Object optional
onHide : function optional

called after hidden

onShow : function optional

called before showing

scope : string optional

showing a floater will hide all other floaters of same scope

Instance Methods

Hide the dropdown and remove -active class from the anchor

Returns

Dropdown

this

Show the dropdown and add -active class to the anchor

Returns

Dropdown

this

Toggle the floater visibility

Parameters

shouldHide : boolean optional

explicitly show or hide. If omitted, toggles based on current visibility.

Returns

Floater

this

Events

Fired when the floater is hidden

Fired when the floater is shown