Dropdown
A menu that 'drops down' when clicked/tapped, showing options to choose from or actions to take.
Class Reference Basic Dropdowns
Toggle
Details(
Summary('open or close', cls='btn m-1'),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
cls='menu dropdown-content bg-base-100 rounded-box z-[1] w-52 p-2 shadow-sm'
),
cls='dropdown'
)
Auto-import documentation coming soon...
## Accessibility Considerations
We use `div` instead of native `<button>` elements due to a
[long-standing Safari bug](https://bugs.webkit.org/show_bug.cgi?id=22261)
that prevents proper button focus management.
**Why this approach works:**
- `tabindex="0"` enables keyboard focus
- `role="button"` provides proper ARIA semantics
- Works consistently across all modern browsers
- Maintains full accessibility compliance
This pattern follows WAI-ARIA authoring practices for custom controls
while working around browser inconsistencies.
Behaviors
Hover
Div(
Div('Hover', tabindex='0', role='button', cls='btn m-1'),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls='dropdown dropdown-hover'
)
Auto-import documentation coming soon...
Positioning
Start
Div(
Div("Start", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-start"
)
Auto-import documentation coming soon...
End
Div(
Div("End", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-end"
)
Auto-import documentation coming soon...
Center
Div(
Div("Center", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-center"
)
Auto-import documentation coming soon...
Top
Div(
Div("Top", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-top"
)
Auto-import documentation coming soon...
Top Center
Div(
Div("Top Center", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-top dropdown-center"
)
Auto-import documentation coming soon...
Top End
Div(
Div("Top End", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-top dropdown-end"
)
Auto-import documentation coming soon...
Bottom (default)
Div(
Div("Bottom (default)", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-bottom"
)
Auto-import documentation coming soon...
Bottom (default) End
Div(
Div("Bottom (default) End", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-bottom dropdown-end"
)
Auto-import documentation coming soon...
Left
Div(
Div("Left", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-left"
)
Auto-import documentation coming soon...
Left Center
Div(
Div("Left Center", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-left dropdown-center"
)
Auto-import documentation coming soon...
Left End
Div(
Div("Left End", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-left dropdown-end"
)
Auto-import documentation coming soon...
Right
Div(
Div("Right", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-right"
)
Auto-import documentation coming soon...
Right End
Div(
Div("Right End", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-right dropdown-end"
)
Auto-import documentation coming soon...
Right Center
Div(
Div("Right Center", tabindex="0", role="button", cls="btn m-1"),
Ul(
Li(A('Item 1')),
Li(A('Item 2')),
tabindex='0',
cls='dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow'
),
cls="dropdown dropdown-right dropdown-center"
)
Auto-import documentation coming soon...
Advanced Examples
Click
Card Title
Custom dropdown content
Div(
Div('Click', tabindex='0', role='button', cls='btn m-1'),
Div(
Div(
H3('Card title!', cls='card-title'),
P('you can use any element as a dropdown.'),
cls='card-body'
),
tabindex='0',
cls='dropdown-content card card-compact bg-primary text-primary-content z-[1] w-64 p-2 shadow'
),
cls='dropdown'
)
Auto-import documentation coming soon...
A normal text and a helper dropdown
Need more info?
Detailed description here
Div(
"A normal text and a helper dropdown",
Div(
Div(
SVG,
tabindex="0",
role="button",
cls="btn btn-circle btn-ghost btn-xs text-info"
),
Div(
Div(
H2("Need more info?", cls="card-title"),
P("Detailed description here"),
tabindex="0",
cls="card-body"
),
tabindex="0",
cls="dropdown-content card compact bg-base-100 rounded-box z-[1] w-64 shadow"
),
cls="dropdown dropdown-end"
)
)
Auto-import documentation coming soon...
Class Reference
Class | Type | Description |
---|---|---|
dropdown | Component | Base dropdown container |
dropdown-content | Part | Dropdown menu container |
dropdown-start | Placement | Aligns dropdown to start of button [Default] |
dropdown-center | Placement | Aligns dropdown to center of button |
dropdown-end | Placement | Aligns dropdown to end of button |
dropdown-top | Placement | Opens above trigger |
dropdown-bottom | Placement | Opens below trigger [Default] |
dropdown-left | Placement | Opens to the left |
dropdown-right | Placement | Opens to the right |
dropdown-hover | Modifier | Opens on hover |
dropdown-open | Modifier | Force open state |
Do you have a question? ask the community
Do you see a bug? open an issue on GitHub
LLMs Context: Full Markdown | This Component