📄Layouts & Menus
Layouts
Sidebar layout
This is the typical web application layout. It allows for a large number of menu items on the sidebar.
Stacked layout
A stacked layout with a navbar and then content.
Menus
In menus.ex
there is a list of all the menu items. This can be useful when working with navbars and layouts, where you sometimes need to loop over menu items multiple times.
For all menu items, you must define a new get_link/2
function, which takes a name
and current_user
as the parameters. The name
parameter is pattern matched and thus you statically include it in the function definition. A menu item has a name, label, path and icon. Here's an example of a menu item for the "Register" menu item:
You can use the current_user
param to conditionally display a menu item. For example, here we don't show the menu item unless the user is an admin.
You can build menu item lists to give to layouts. We define the two core menu lists in menus.ex
:
Last updated