v0.0.2
Demos (demo panel, opens in a new tab)

Menu items

The parts of the vertical menu: section heading, link, group with a submenu, third-level subgroup and the "Coming soon" item.

zb:nav.* zubazar/ui-pro

PRO

This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →

Groups

Groups: view
BLADE

zb:nav.group gathers sub-links (zb:nav.sub-item) in a collapsible group; pass active to the group of the active page.

blade
<nav class="flex flex-col gap-0.5 px-3">
    <zb:nav.group title="Customers" active>
        <zb:slot:icon><zb:icon name="users" /></zb:slot:icon>
        <zb:nav.sub-item href="#" title="Customer List" active />
        <zb:nav.sub-item href="#" title="Customer Groups" />
    </zb:nav.group>
    <zb:nav.group title="Reports">
        <zb:slot:icon><zb:icon name="document-text" /></zb:slot:icon>
        <zb:nav.sub-item href="#" title="Sales Report" />
        <zb:nav.sub-item href="#" title="Stock Report" />
    </zb:nav.group>
</nav>
PropValues
group: titleGroup name (required)
group: activetrue | false
sub-item: href, title, activeSub-link; highlighted on the guide line when active

Third level

Third level: view
BLADE

If a group needs one more level, use zb:nav.sub-group; if the active page is inside it, active makes it open.

blade
<nav class="flex flex-col gap-0.5 px-3">
    <zb:nav.group title="Definitions" active>
        <zb:slot:icon><zb:icon name="cog-6-tooth" /></zb:slot:icon>
        <zb:nav.sub-item href="#" title="Carriers" />
        <zb:nav.sub-group title="Address" active>
            <zb:nav.sub-item href="#" title="Districts" active />
            <zb:nav.sub-item href="#" title="Neighborhoods" />
        </zb:nav.sub-group>
    </zb:nav.group>
</nav>
PropValues
sub-group: titleSubgroup name (required)
sub-group: activetrue | false

Badges

Badges: view
BLADE

badge adds a number or a short label such as "New" to the right of the item.

blade
<nav class="flex flex-col gap-0.5 px-3">
    <zb:nav.item href="#" title="Support tickets" badge="12">
        <zb:slot:icon><zb:icon name="inbox" /></zb:slot:icon>
    </zb:nav.item>
    <zb:nav.group title="Imports" badge="New" active>
        <zb:slot:icon><zb:icon name="arrow-up-tray" /></zb:slot:icon>
        <zb:nav.sub-item href="#" title="Product Import from Excel" badge="3" />
        <zb:nav.sub-group title="Pending" badge="5" active>
            <zb:nav.sub-item href="#" title="Awaiting approval" badge="2" />
        </zb:nav.sub-group>
    </zb:nav.group>
</nav>
PropValues
badgeNumber or short text; not shown when null

Coming soon

Coming soon: view
BLADE

zb:nav.coming-soon shows a page that is not ready yet as non-clickable, with a "Coming soon" label on its right; change the label with label.

blade
<nav class="flex flex-col gap-0.5 px-3">
    <zb:nav.group title="Training" active>
        <zb:slot:icon><zb:icon name="academic-cap" /></zb:slot:icon>
        <zb:nav.sub-item href="#" title="Frequently asked questions" />
        <zb:nav.coming-soon title="Training videos" />
        <zb:nav.coming-soon title="Live support" label="March" />
    </zb:nav.group>
</nav>
PropValues
coming-soon: labelLabel on the right; defaults to "Coming soon"

Props

The values the component takes. What are props and slots?

PropTypeDefaultDescription
nav.heading: firstbooleanfalseReduces the top spacing of the first heading; the heading text comes from the slot
nav.item: href, title— — Link URL and text (required)
nav.item: activebooleanfalseActive page; highlight and aria-current="page"
nav.item: badge—nullNumber or short label on the right
nav.item: target—null'_blank' opens it in a new tab (wire:navigate is not used); adds an arrow icon and a screen reader note
nav.item: externalbooleanfalseSame as target='_blank': new tab, arrow icon and screen reader note
nav.group: title— — Group name (required)
nav.group: activebooleanfalseThe group is rendered open and highlighted on the server
nav.group: badge—nullNumber or short label on the right
nav.sub-group: title— — Name of the third-level, collapsible subgroup (required)
nav.sub-group: activebooleanfalseThe subgroup is rendered open and highlighted on the server
nav.sub-group: badge—nullNumber or short label on the right
nav.sub-item: href, title— — URL and text of the sub-link (required)
nav.sub-item: active, badge, target, external—false · null · null · falseSame as nav.item
nav.sub-item: compactbooleanfalseBoxed look for the horizontal menu panel
nav.coming-soon: title— — Item name (required)
nav.coming-soon: label, compact—null · falseLabel text ("Coming soon"); boxed look for the horizontal menu panel
(attributes)— — class, data-*, wire:key, wire:click … are added to the element itself on item, sub-item, coming-soon and heading (class is merged), and to the wrapping div on group and sub-group

Slots: nav.item and nav.group: icon · nav.group and nav.sub-group: default (child items) · nav.heading: heading text

Advanced

1 example

Developer notes

Events, hooks and details
  • Groups work like an accordion: only one group stays open at a time. Since the group of the active page is rendered open on the server, the menu looks right even before Alpine loads.
  • Pass first on the first heading to reduce its top spacing; an item's icon comes from the icon slot. The active item is highlighted and gets aria-current="page".
  • In the collapsed menu, headings are hidden and item names show as tooltips.
  • badge works on every level of the menu (nav.item, nav.group, nav.sub-group, nav.sub-item); if you build the menu from JSON, zb:menu passes the item's badge value to the same component.
  • external works on zb:nav.item, zb:nav.sub-item and zb:nav.horizontal-item.
Zubazar UI · ZubazarDesigned for people.