Menus are used to display a list of options for users to choose from.
Menus typically contain a list of links or buttons that users can click. The styling is very minimal, just adding a hover effect.
= daisy_menu do |menu|
- # Menu Item Group with a title keyword argument
- menu.with_item(title: "Group 1") do
= link_to "Item 1 - 1", "#"
- # Menu Item Group with a title as the first positional argument
- menu.with_item("Group 2") do
= link_to "Item 2 - 1", "#"
- menu.with_item do
= link_to "Item 2 - 2", "#"
Menus can be displayed horizontally by adding the
.menu-horizontal
class to the menu. They can also have icons,
disabled / active items, and many other options.
.pointer-events-none
to ensure it
cannot be clicked. You may also want to add tabindex: -1
to
your link to ensure it cannot be focused with the keyboard.
Menus can also contain nested menus. This is useful for organizing a large number of options.
- icon_options = { css: "size-4 mr-1 text-slate-600", variant: :mini }
= daisy_menu(css: "bg-base-100 border border-base-300 rounded-lg shadow-md") do |menu|
- menu.with_item do
= link_to "#" do
= hero_icon("home", **icon_options)
Home
- menu.with_item do
= link_to "#" do
= hero_icon("bell-alert", **icon_options)
Notifications
- menu.with_item(title: "Parent") do
= daisy_menu do |menu|
- menu.with_item do
= link_to "Child 1", "#"
- menu.with_item do
= link_to "Child 2", "#"
- menu.with_item do
- icon_options[:css] += " !text-yellow-500"
= link_to "#" do
Child 3
= hero_icon("bolt", **icon_options)