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

Horizontal menu

The top menu of the horizontal layout: single links and groups with a dropdown panel.

zb:nav.horizontal-* zubazar/ui-pro

PRO

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

Basic usage

Basic usage: view
BLADE

zb:nav.horizontal-item is a single link and zb:nav.horizontal-group a group with a dropdown panel.

blade
<nav class="flex h-12 items-center gap-1">
    <zb:nav.horizontal-item href="#" title="Home" />
    <zb:nav.horizontal-group title="Customers">
        <zb:nav.sub-item compact href="#" title="Customer List" />
    </zb:nav.horizontal-group>
    <zb:nav.horizontal-group title="Imports">
        <zb:nav.sub-item compact href="#" title="Product Import from Excel" />
        <zb:nav.coming-soon compact title="Users from Excel" />
    </zb:nav.horizontal-group>
</nav>
PropValues
horizontal-item: href, titleLink URL and text (required)
horizontal-group: titleGroup name (required)
sub-item: compacttrue (inside the panel)

Active page

Active page: view
BLADE

Pass active to the active link or to the group that contains the active page; a thin accent line appears below it.

blade
<nav class="flex h-12 items-center gap-1">
    <zb:nav.horizontal-item href="#" title="Home" />
    <zb:nav.horizontal-group title="Reports" active>
        <zb:nav.sub-item compact href="#" title="Sales Report" active />
        <zb:nav.sub-item compact href="#" title="Stock Report" />
    </zb:nav.horizontal-group>
    <zb:nav.horizontal-item href="#" title="Orders" />
</nav>
PropValues
activetrue | false

Badges

Badges: view
BLADE

badge shows a number or a short label after the name of the link or group.

blade
<nav class="flex h-12 items-center gap-1">
    <zb:nav.horizontal-item href="#" title="Support tickets" badge="12" />
    <zb:nav.horizontal-group title="Imports" badge="New">
        <zb:nav.sub-item compact href="#" title="Product Import from Excel" badge="3" />
        <zb:nav.sub-item compact href="#" title="Import history" />
    </zb:nav.horizontal-group>
</nav>
PropValues
badgeNumber or short text; not shown when null

Groups on the right edge

Groups on the right edge: view
BLADE

For groups at the right end of the menu (e.g. Settings), pass align="right" so the panel does not overflow the screen.

blade
<nav class="flex h-12 items-center gap-1">
    <zb:nav.horizontal-item href="#" title="Home" />
    <div class="flex-1"></div>
    <zb:nav.horizontal-group title="Settings" align="right">
        <zb:nav.sub-item compact href="#" title="Users" />
        <zb:nav.sub-item compact href="#" title="Permissions" />
    </zb:nav.horizontal-group>
</nav>
PropValues
alignleft | right

With a JSON menu

BLADE

If the menu comes from a JSON file, use the zb:menu component with horizontal instead of writing the items one by one; section headings are skipped in the horizontal menu.

blade
<zb:slot:nav>
    <zb:menu menu="main" horizontal />
</zb:slot:nav>

<zb:slot:mobileNav>
    <zb:menu menu="main" />
</zb:slot:mobileNav>

Props

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

PropTypeDefaultDescription
horizontal-item: href, title— — Link URL and text (required)
horizontal-item: activebooleanfalseAccent line below it and aria-current="page"
horizontal-item: target—null'_blank' opens it in a new tab (wire:navigate is not used); adds an arrow icon and a screen reader note
horizontal-item: externalbooleanfalseSame as target='_blank': new tab, arrow icon and screen reader note
horizontal-item: badge—nullNumber or short label after the name
horizontal-group: title— — Group name (required)
horizontal-group: activebooleanfalseGroup that contains the active page; accent line
horizontal-group: align—leftleft · right (alignment of the panel)
horizontal-group: badge—nullNumber or short label after the name
sub-item: badge—nullBadge of the sub-item in the panel
sub-item: compactbooleanfalseBoxed look inside the panel; pass true in the horizontal menu
coming-soon: compactbooleanfalseBoxed look inside the panel
(attributes)— — class, data-*, wire:key … are added to the link itself on horizontal-item (class is merged) and to the wrapping div on horizontal-group

Slots: horizontal-item and horizontal-group: icon · horizontal-group: default (panel items)

Advanced

2 examples

Icons

Icons: view
BLADE

Both items accept the icon slot; the icon is placed to the left of the text. Since space is tight in the top menu, keep icons small with size="4".

blade
<nav class="flex h-12 items-center gap-1">
    <zb:nav.horizontal-item href="#" title="Home" active>
        <zb:slot:icon><zb:icon name="home" size="4" /></zb:slot:icon>
    </zb:nav.horizontal-item>
    <zb:nav.horizontal-group title="Customers">
        <zb:slot:icon><zb:icon name="users" size="4" /></zb:slot:icon>
        <zb:nav.sub-item compact href="#" title="Customer List" />
    </zb:nav.horizontal-group>
</nav>

Developer notes

Events, hooks and details
  • The panel opens on mouse hover or when keyboard focus moves into it; no JavaScript is needed.
  • For the links in the panel, use zb:nav.sub-item and zb:nav.coming-soon with compact.
  • In the layout the menu fills the height of the top bar; in the example this height is set with h-12.
  • The active sub-item in the panel is marked with a gray background.
  • You can pass badge to the sub-items in the panel too; zb:menu passes the badge value in the JSON to the horizontal items as well.
Zubazar UI · ZubazarDesigned for people.