Skip to main content

Dropdown

The Dropdown component is a versatile dropdown menu that shows or hides its content when the label is clicked. Below you will find detailed information about its props and how to use it.

Props

PropTypeDefaultDescription
childrenReactNodeRequiredThe content to display inside the dropdown.
labelReactNodeRequiredThe element that, when clicked, toggles the dropdown.
align'right' | 'left' | 'top''right'The alignment of the dropdown content relative to the label.
widthstring'300px'The minimum width of the dropdown content.

Example Usage

Basic Dropdown

<Dropdown
label={<button>Open Menu</button>}
align="left"
>
<ul>
<li>Option 1</li>
<li>Option 2</li>
<li>Option 3</li>
</ul>
</Dropdown>
<Dropdown
label={<span>Profile</span>}
align="right"
>
<div>
<p>User: Jane Doe</p>
<button onClick={() => alert('Logout clicked')}>Logout</button>
</div>
</Dropdown>

Demo