Dropdown (extends Floater)
Assign a floater panel to a MouseEvent
Example
Syntax
new Dropdown({
content: createElement({
class: 'bg-white pad',
content: 'Hello World'
}),
anchor: '#hi-button'
})
HTML
<komp-dropdown anchor="#hi-button">
Hello World
</komp-dropdown>
Options
| types | description | required | default | type | |
|---|---|---|---|---|---|
content
|
String, HTMLElement, Array, Object |
content for the floater, uses Dolla's |
|||
anchor
|
String, HTMLElement |
element to append floater to. If |
true | null/anchor.parentElement | |
placement
|
String |
how the floater is anchored options like "top", "top-start", "top-end", "left", "left-start"... |
bottom | ||
strategy
|
String |
how the floater is positioned in the document. "absolute" or "fixed" |
absolute | ||
flip
|
Boolean, Object |
See https://floating-ui.com/docs/flip, defaults to false in favor of autoPlacement |
false | ||
offset
|
Boolean, Object | false | |||
shift
|
Boolean, Object | true | |||
arrow
|
Boolean, Number |
True to show default size, or number in pixels |
false | ||
size
|
Boolean, Object | false | |||
autoPlacement
|
Boolean, Object | true | |||
inline
|
Boolean, Object | false | |||
autoUpdate
|
Boolean, Object | true | |||
removeOnBlur
|
Boolean |
Hide dropdown when user clicks outside or focuses elsewhere |
true | ||
timeout
|
Number |
Milliseconds to wait before hiding dropdown after mouseleave |
0 | ||
onHide
|
Function |
called after hidden |
|||
onShow
|
Function |
called before showing |
|||
scope
|
showing a floater will hide all other floaters of same scope |
String | |||
mouseevent
|
String |
MouseEvent that toggles floater |
click |
Methods
| parameters | return | description | |
|---|---|---|---|
show
|
[] | this |
Shows the dropdown and adds the -active class to the anchor element |
hide
|
[] | this |
Hides the dropdown and removes the -active class from the anchor element |
toggle
|
["optional shouldHide:Boolean"] | this |
Toggles the dropdown visibility. If shouldHide is provided, will explicitly show or hide |