Dropdown
Examples
* Adding a dropdown id is recommended.
- Dashboard
- Settings
- Earnings
- Sign out
<script>
import { Dropdown, DropdownItem} from 'flowbite-svelte'
</script>
<Dropdown label="Dropdown button">
<DropdownItem>Dashboard</DropdownItem>
<DropdownItem>Settings</DropdownItem>
<DropdownItem>Earnings</DropdownItem>
<DropdownItem>Sign out</DropdownItem>
</Dropdown>
Dropdown divider
- Dashboard
- Settings
- Earnings
- Separated link
<Dropdown label="Dropdown button">
<DropdownItem>Dashboard</DropdownItem>
<DropdownItem>Settings</DropdownItem>
<DropdownItem>Earnings</DropdownItem>
<DropdownDivider />
<DropdownItem>Separated link</DropdownItem>
</Dropdown>
Dropdown header
- Dashboard
- Settings
- Earnings
- Sign out
Bonnie Green
name@flowbite.com
<Dropdown label="Dropdown button">
<DropdownHeader>
<span class="block text-sm"> Bonnie Green </span>
<span class="block truncate text-sm font-medium"> name@flowbite.com </span>
</DropdownHeader>
<DropdownItem>Dashboard</DropdownItem>
<DropdownItem>Settings</DropdownItem>
<DropdownItem>Earnings</DropdownItem>
<DropdownDivider />
<DropdownItem>Sign out</DropdownItem>
</Dropdown>
Dropdown navbar
You can also use the dropdown element inside a navigation bar and add a second level of navigation hierarchy, but make sure to use Navbar components.
<Navbar let:hidden let:toggle>
<NavBrand href="/">
<img
src="https://flowbite.com/docs/images/logo.svg"
class="mr-3 h-6 sm:h-9"
alt="Flowbite Logo"
/>
<span class="self-center whitespace-nowrap text-xl font-semibold dark:text-white">
Flowbite
</span>
</NavBrand>
<NavHamburger on:click={toggle} />
<NavUl {hidden}>
<NavLi href="/" active={true}>Home</NavLi>
<Dropdown label="Dropdown" inline={true} placement="bottom-start">
<DropdownItem>Dashboard</DropdownItem>
<DropdownItem>Settings</DropdownItem>
<DropdownItem>Earnings</DropdownItem>
<DropdownDivider />
<DropdownItem>Sign out</DropdownItem>
</Dropdown>
<NavLi href="/services">Services</NavLi>
<NavLi href="/pricing">Pricing</NavLi>
<NavLi href="/contact">Contact</NavLi>
</NavUl>
</Navbar>
Sizes
The dropdown menus work with buttons of all sizes including smaller or larger ones.
- Dashboard
- Settings
- Earnings
- Sign out
- Dashboard
- Settings
- Earnings
- Sign out
<Dropdown label="Small dropdown" size="sm">
<DropdownItem>Dashboard</DropdownItem>
<DropdownItem>Settings</DropdownItem>
<DropdownItem>Earnings</DropdownItem>
<DropdownItem>Sign out</DropdownItem>
</Dropdown>
<Dropdown label="Large dropdown" size="lg">
<DropdownItem>Dashboard</DropdownItem>
<DropdownItem>Settings</DropdownItem>
<DropdownItem>Earnings</DropdownItem>
<DropdownItem>Sign out</DropdownItem>
</Dropdown>
Placement
You can also use the placement="top|right|bottom|left" options to choose the placement of the dropdown menu. By default the positioning is set to the bottom side of the button.
- Dashboard
- Settings
- Earnings
- Sign out
- Dashboard
- Settings
- Earnings
- Sign out
- Dashboard
- Settings
- Earnings
- Sign out
- Dashboard
- Settings
- Earnings
- Sign out
<Dropdown label="Dropdown top" placement="top">
<DropdownItem>Dashboard</DropdownItem>
<DropdownItem>Settings</DropdownItem>
<DropdownItem>Earnings</DropdownItem>
<DropdownItem>Sign out</DropdownItem>
</Dropdown>
<Dropdown label="Dropdown right" placement="right">
<DropdownItem>Dashboard</DropdownItem>
<DropdownItem>Settings</DropdownItem>
<DropdownItem>Earnings</DropdownItem>
<DropdownItem>Sign out</DropdownItem>
</Dropdown>
<Dropdown label="Dropdown bottom" placement="bottom">
<DropdownItem>Dashboard</DropdownItem>
<DropdownItem>Settings</DropdownItem>
<DropdownItem>Earnings</DropdownItem>
<DropdownItem>Sign out</DropdownItem>
</Dropdown>
<Dropdown label="Dropdown left" placement="left">
<DropdownItem>Dashboard</DropdownItem>
<DropdownItem>Settings</DropdownItem>
<DropdownItem>Earnings</DropdownItem>
<DropdownItem>Sign out</DropdownItem>
</Dropdown>
- Dashboard
- Settings
- Earnings
- Sign out
- Dashboard
- Settings
- Earnings
- Sign out
Props
The component has the following props, type, and default values. See types page for type information.
Dropdown
Name | Type | Default |
---|---|---|
label | string | '' |
inline | boolean | false |
tooltipArrow | boolean | false |
arrowIcon | boolean | true |
labelClass | string | 'flex items-center justify-between w-full py-2 pl-3 pr-4 font-medium text-gray-700 border-b border-gray-100 hover:bg-gray-50 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 md:w-auto dark:text-gray-400 dark:hover:text-white dark:focus:text-white dark:border-gray-700 dark:hover:bg-gray-700 md:dark:hover:bg-transparent' |
placement | 'auto' | Placement | 'bottom' |
DropdownDivider
Name | Type | Default |
---|---|---|
divClass | string | 'my-1 h-px bg-gray-100 dark:bg-gray-600' |
DropdownHeader
Name | Type | Default |
---|---|---|
divClass | string | 'block py-2 px-4 text-sm text-gray-700 dark:text-gray-200' |
DropdownItem
Name | Type | Default |
---|---|---|
liClass | string | 'block cursor-pointer py-2 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-600 dark:hover:text-white' |