Menus & navigation JS behaviour

Admin shell

The frame a whole admin page lives in: a collapsible sidebar with a springy highlight, a topbar with search and a user menu; under 48rem the sidebar becomes a drawer.

Real scenarios

The component as it is used in a product — not a specimen grid.

A whole shop panel in one component

Click around the sidebar — the active item syncs to Livewire through wire:model, the highlight springs after it, and the content area follows. The toggle at the bottom of the sidebar collapses it; shrink the window under 48rem and the topbar’s menu button opens the drawer.

Dashboard

Today's pulse

Clara Meyer

Sales lead


Orders today
128 +12 vs yesterday
Visits
9,412
Conversion
3 %

Active item on the server: dashboard

A second frame, custom seats

The search seat takes a real input through the search slot, and the heading slot replaces title/subtitle with your own markup.

beta

Notes

Whatever you typed: —

Important props

Important props
Prop Type Default What it does
groups array [] Nav groups: each with label and items; an item takes id, label, icon, badge, href and disabled. Without href it is a button synced through wire:model on the root.
active string null The active item id; wire:model="state.page" on the root binds it to Livewire (x-modelable) and the spring highlight follows it.
collapsed bool false Start collapsed; the toggle at the bottom of the sidebar flips it (the width springs).
title / subtitle string null Topbar heading and subheading; replaceable via the heading slot.
user array null name, role, avatar and menu for the user menu; the userMenu slot takes arbitrary markup.
height / min-height string null Sets the frame height with CSS (e.g. 34rem); defaults to the full viewport.
slots — — sidebar, topbar, search, actions, title, heading and userMenu — each replaces the built-in built from the props.

Snippet

<x-nx::admin-shell brand="فروشگاه نابو" :active="$state['page'] ?? 'dashboard'" wire:model="state.page"
    title="داشبورد" subtitle="خلاصهٔ امروز" :groups="$nav" :user="$user" height="34rem">
    <x-slot:actions>
        <x-nx::theme-toggle />
        <x-nx::activity-dropdown :items="$activity" />
    </x-slot:actions>
    … محتوای پنل …
</x-nx::admin-shell>