Dropdown
Examples
A dropdown must be associated with an activator, commonly a button, which, at the time of being clicked, expands the dropdown. Activator and dropdown should be contained in a div with a chi-dropdown
class, or otherwise, the activator must reference the dropdown with a data-target
attribute. Use the chi-dropdown__trigger
class on your activator button to make the chevron appear.
Menu
Icons
Dropdown component has been developed to support Chi icons in the menu items.
Checkboxes
Helpers
Web Component
JavaScript
Properties
Methods
Method | Description | Returns |
---|---|---|
hide() => void | Hides the dropdown | Type: void |
show() => void | Shows the dropdown | Type: void |
toggle() => void | Toggles active state (show/hide) | Type: void |
Events
Event | Description |
---|---|
chiDropdownShow | Dropdown show has been triggered. |
chiDropdownHide | Dropdown hide has been triggered. |
Preventing memory leaks
Dropdown components have a dispose function to free all resources attached to the element, such as event listeners and object data. You must call this method when you want to remove the component.
It is safe to call the dropdown
method more than once, as it will return any previously created dropdown component associated with the trigger.