Tailwind CSS Dropdown
The Dropdown component is designed to present users with a neat and organized list of actions or additional content. Enabled by a JavaScript dropdown plugin, it ensures a smooth, collapsible interface for enhanced navigation and space efficiency.
Requires JS
Note that this component requires the use of the third-party Floating UI plugin, else you can skip this message if you are already using Preline UI as a package.
Custom trigger button
Use a fully custom trigger while keeping the same dropdown menu behavior.
Inner translate animation
When Floating UI positions the menu with transforms, apply animation classes to an inner wrapper with data-hs-transition and translate utilities.
Auto close behavior
Control whether the dropdown closes on inside clicks, outside clicks, or both by using [--auto-close:inside], [--auto-close:outside], or [--auto-close:false].
Scope to window
Position the dropdown relative to the viewport instead of the parent container, which is helpful inside clipped or overflow: hidden layouts.
Bottom placements
Use [--placement:bottom | bottom-left | bottom-right] to place dropdown menus below the trigger.
This example uses [--placement:bottom-left] class.
Top placements
Use [--placement:top | top-left | top-right] to place dropdown menus above the trigger.
This example uses [--placement:top-left] class.
Right-side placements
Use [--placement:right | top-right | bottom-right] to place dropdown menus to the right of the trigger.
This example uses [--placement:bottom-right] class.
Left-side placements
Use [--placement:left | top-left | bottom-left] to place dropdown menus to the left of the trigger.
This example uses [--placement:bottom-left] class.
Breakpoint-based alignment
Change dropdown placement at different breakpoints.
Resize the window to see the alignment change.
Breakpoint-based alignment in RTL
Apply the same responsive placement patterns in right-to-left layouts.
Destroy and reinitialize
Use the destroy method before reinitializing the component when dropdown instances need to be rebuilt.