The name is used to identify the menu item. It is used to highlight the current menu item.
<.sidebar_layoutcurrent_page={:sign_in}...>
Label
This is the text that will be displayed in the menu.
Path
This is the path that the user will be taken to when they click the menu item.
The default link type is a live_redirect. This will work for non-live view links too.
Live patching
Let's say you have three menu items that point to the same live view. In this case we can utilize a live_patch link. To do this, you add the patch_group key to the menu item.
Now, if you're on page :one, and click a link in the menu to either :two, or :three, the live view will be patched because they are in the same patch_group. If you click :another_link, the live view will be redirected.
Icons
The icon should match to a Heroicon (Petal Components must be installed).
If you have your own icon, you can pass a function to the icon attribute instead of an atom:
Sidebar supports multi menu groups for the side menu. eg:
User
Profile
Settings
Company
Dashboard
Company Settings
To enable this, change the structure of main_menu_items to this:
main_menu_items=[%{title:"Menu group 1",menu_items:[...menuitems...]},%{title:"Menu group 2",menu_items:[...menuitems...]},]
Attributes
menu_items (:list) (required)
current_page (:atom) (required)
title (:string) - Defaults to nil.
on_toggle (Phoenix.LiveView.JS) - additional JS commands to run when a submenu is toggled (LiveView.JS only). Defaults to %Phoenix.LiveView.JS{ops: []}.
vertical_menu_item(assigns)
Attributes
current_page (:atom)
path (:string) - Defaults to nil.
icon (:any) - Defaults to nil.
label (:string)
name (:atom) - Defaults to nil.
menu_items (:list) - Defaults to nil.
all_menu_items (:list) - Defaults to nil.
patch_group (:atom) - Defaults to nil.
link_type (:string) - Defaults to "live_redirect".
on_toggle (Phoenix.LiveView.JS) - Defaults to %Phoenix.LiveView.JS{ops: []}.