Skip to content

WIP: Add Dropdown component - #130

Open
koppen wants to merge 2 commits into
mainfrom
dropdown
Open

WIP: Add Dropdown component#130
koppen wants to merge 2 commits into
mainfrom
dropdown

Conversation

@koppen

@koppen koppen commented Aug 10, 2026

Copy link
Copy Markdown
Member

WIP: How to handle Javascript for the trigger? We don't want to assume the Flowbite.js is loaded, or do we? How about people using Stimulus controllers? Or HTML dialogs?

@koppen
koppen changed the base branch from main to spinner August 10, 2026 11:13
Base automatically changed from spinner to main August 10, 2026 11:23
@koppen
koppen requested a lite review from Copilot August 11, 2026 07:40
@koppen koppen changed the title Add Dropdown component WIP: Add Dropdown component Aug 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Flowbite dropdown ViewComponent (plus item and icon subcomponents) along with Lookbook previews and component tests, to support rendering dropdown menus in the component library.

Changes:

  • Introduces Flowbite::Dropdown with an ERB template that renders a trigger button and hidden menu container.
  • Adds Flowbite::Dropdown::Item and Flowbite::Dropdown::ChevronIcon subcomponents.
  • Adds Minitest coverage and a Lookbook preview for the new dropdown component.

Reviewed changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/components/flowbite/dropdown_test.rb Adds rendering and attribute assertions for dropdown, item, and chevron icon components.
demo/test/components/previews/dropdown_preview.rb Adds Lookbook previews demonstrating dropdown usage, styles, and button-style items.
demo/.yardoc/checksums Updates YARD checksums to include the new dropdown component files.
app/components/flowbite/dropdown.rb Introduces the main dropdown component API and default menu classes.
app/components/flowbite/dropdown/dropdown.html.erb Adds the dropdown markup wiring the trigger button to the menu container.
app/components/flowbite/dropdown/item.rb Adds a dropdown menu item component that renders as a link or button.
app/components/flowbite/dropdown/chevron_icon.rb Adds the chevron-down SVG icon component used in the trigger button.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@@ -0,0 +1,17 @@
<div class="relative inline-block">
<%= render(Flowbite::Button.new(id: button_id, "data-dropdown-toggle": id, **button_options)) do %>
Comment on lines +6 to +8
# The dropdown menu itself is toggled using Flowbite's JavaScript, via the
# +data-dropdown-toggle+ attribute. Make sure Flowbite's JavaScript is
# loaded on the page for the toggle behavior to work.
Comment on lines +36 to +58
def call
content_tag(:li) { render_link }
end

private

def classes
self.class.classes + @class
end

def link?
href.present?
end

def render_link
link_options = {class: classes}.merge(options)

if link?
content_tag(:a, content, href: href, **link_options)
else
content_tag(:button, content, type: "button", **link_options)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants