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

User menu

The user dropdown menu on the right of the top bar, showing the initials of the name.

zb:user-menu 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

name is required; put the menu items in the slot with zb:dropdown.item.

blade
<zb:user-menu name="Ayşe Yılmaz">
    <zb:dropdown.item href="#">Profile</zb:dropdown.item>
    <zb:dropdown.item href="#">Settings</zb:dropdown.item>
    <zb:dropdown.item>Log Out</zb:dropdown.item>
</zb:user-menu>
PropValues
nameName of the user (required)

Initials

Initials: view
BLADE

The initials come from the first two words of the name ("Mehmet Ali Kaya" → MA); for a different abbreviation, pass initials.

blade
<zb:user-menu name="Mehmet Ali Kaya">
    <zb:dropdown.item href="#">Profile</zb:dropdown.item>
</zb:user-menu>
<zb:user-menu name="Mehmet Ali Kaya" initials="MK">
    <zb:dropdown.item href="#">Profile</zb:dropdown.item>
</zb:user-menu>
PropValues
initialsGenerated from the name when not given

In the layout

BLADE

Put the menu in the layout's userMenu slot; for logging out, use a form containing @csrf and an item with type="submit".

blade
<zb:slot:userMenu>
    <zb:user-menu :name="auth()->user()->name">
        <zb:dropdown.item :href="route('profile.edit')" wire:navigate>Settings</zb:dropdown.item>
        <form method="POST" action="{{ route('logout') }}">
            @csrf
            <zb:dropdown.item type="submit">Log Out</zb:dropdown.item>
        </form>
    </zb:user-menu>
</zb:slot:userMenu>

Props

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

PropTypeDefaultDescription
name— — Name of the user (required)
initials—nullGenerated from the first two words of the name when not given (Ayşe Yılmaz → AY)

Slots: default (menu items: zb:dropdown.item)

Developer notes

Events, hooks and details
  • The button shows the initials and, at sm and up, the name too; the menu opens aligned to the button's right edge and closes when an item is clicked.
  • Add wire:navigate to page links. Other attributes given to the component (e.g. aria-label, class) go to the button that opens it.
Zubazar UI · ZubazarDesigned for people.