Renders a navigation bar.
<.navbar>
<:brand><.link navigate={~p"/"}>Pet Clinic</.link></:brand>
<.navbar_items>
<:item><.link navigate={~p"/about"}>About</.link></:item>
<:item><.link navigate={~p"/services"}>Services</.link></:item>
<:item>
<.link navigate={~p"/login"} class="button">Log in</.link>
</:item>
</.navbar_items>
</.navbar>
You can place multiple navigation item lists in the inner block. If the
.navbar
is styled as a flex box, you can use the CSS order
property to
control the display order of the brand and lists.
<.navbar>
<:brand><.link navigate={~p"/"}>Pet Clinic</.link></:brand>
<.navbar_items class="navbar-main-links">
<:item><.link navigate={~p"/about"}>About</.link></:item>
<:item><.link navigate={~p"/services"}>Services</.link></:item>
</.navbar_items>
<.navbar_items class="navbar-user-menu">
<:item>
<.button_link navigate={~p"/login"}>Log in</.button_link>
</:item>
</.navbar_items>
</.navbar>
If you have multiple <nav>
elements on your page, it is recommended to set
the aria-label
attribute.
<.navbar aria-label="main navigation">
<!-- ... -->
</.navbar>