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
This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →
Basic usage
BLADE
name is required; put the menu items in the slot with zb:dropdown.item.
<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>
| Prop | Values |
|---|---|
name | Name of the user (required) |
Initials
BLADE
The initials come from the first two words of the name ("Mehmet Ali Kaya" → MA); for a different abbreviation, pass initials.
<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>
| Prop | Values |
|---|---|
initials | Generated 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".
<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?
| Prop | Type | Default | Description |
|---|---|---|---|
name | — | — | Name of the user (required) |
initials | — | null | Generated 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
- The button shows the initials and, at
smand up, the name too; the menu opens aligned to the button's right edge and closes when an item is clicked. - Add
wire:navigateto page links. Other attributes given to the component (e.g.aria-label,class) go to the button that opens it.