Skip to main content

Dropdown Button

The DropdownButton is designed to create a dropdown button with customizable content and behaviors. It's built on top of the popular BasicDropdown component and supports dynamic button configurations, including the ability to use a custom button component. It manages its own internal state and handles various events related to dropdown interactions. It allows for customization of the button's appearance and behavior, including support for loading states, disabled states, and custom icons or images.

Usage

<DropdownButton>
<div class="next-dd-menu">
<div class="p-1">
{{#each-in this.items as |item|}}
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd this.handleClick item)}}>
{{item.title}}
</a>
{{/each-in}}
</div>
</div>
</DropdownButton>

Properties

PropertyTypeDescription
typeStringSpecifies the type of button. Defaults to 'default'.
buttonSizeStringDetermines the size of the button. Defaults to 'md'.
buttonComponentArgsObjectArguments passed to the custom button component, if one is used.
dropdownIdStringID for the dropdown component.
wrapperClassStringCSS class for the dropdown wrapper.
renderInPlaceBooleanIf true, the dropdown will render in place rather than as a separate node.
horizontalPositionStringHorizontal positioning of the dropdown.
verticalPositionStringVertical positioning of the dropdown.
calculatePositionFunctionFunction to calculate the dropdown's position.
defaultClassStringDefault CSS class for the dropdown.
matchTriggerWidthBooleanIf true, the dropdown will match the width of the trigger button.
onOpenFunctionFunction called when the dropdown is opened.
onCloseFunctionFunction called when the dropdown is closed.
buttonComponentComponentA custom component to use for the button.
If not provided, a default <Button /> component is used.
textStringText to display on the button.
buttonClassStringCSS class for the button.
buttonWrapperClassStringCSS class for the button wrapper.
activeBooleanIf true, the button is considered active.
isLoadingBooleanIf true, the button displays a loading state.
disabledBooleanIf true, the button is disabled.
textClassStringCSS class for the text within the button.
helpTextStringText to display in a tooltip when hovering over the button.
tooltipPlacementStringPlacement of the tooltip relative to the button.
imgStringURL of an image to display on the button.
imgClassStringCSS class for the image.
altStringAlt text for the image.
iconStringIcon to display on the button.
iconPrefixStringPrefix for the icon, useful for specifying icon sets.
iconSizeNumberSize of the icon.
iconClassStringCSS class for the icon.

Events

EventDescription
onRegisterAPI()Calls the registerAPI function provided in the arguments, if it exists.
onTriggerInsert()Calls the onTriggerInsert function provided in the arguments, if it exists. Sets _onTriggerInsertFired to true. If renderInPlace is true or _onInsertFired is false, it also calls onInsert.
onButtonInsert()Calls the onButtonInsert function provided in the arguments, if it exists. Sets _onButtonInsertFired to true.
onInsert()Calls the onInsert function provided in the arguments, if it exists.