class Nav extends BeartropyComponent

Full-featured sidebar navigation with categories, nested children, permissions, and active state detection.

Renders a <nav> element driven by Alpine.js for collapse/expand, hover submenus (via x-teleport), and client-side active state reconciliation. Supports two highlight modes: 'standard' (background highlight) and 'text' (text-only highlight with hover). Colors are resolved from presets/nav.php.

Items support permission gating (can, canAny, canMatch) with optional admin bypass, nested children, badges (slot, Alpine, or static), dividers, external links, and tooltips.

Traits

Trait HasPresets.

Trait HasErrorBag.

Properties

string|null $size

Component size (md, lg, etc.) used for preset resolution.

from  BeartropyComponent
array $items

Resolved and permission-filtered navigation items.

string $sidebarBind

Alpine variable name for sidebar collapse binding.

string $highlightMode

Highlight mode: 'standard' (bg) or 'text' (text-only).

string|null $highlightParentClass

CSS classes for active parent items.

string|null $highlightChildClass

CSS classes for active child items.

string|null $itemClass

Base CSS classes for parent items.

string|null $childItemClass

Base CSS classes for child items.

string $categoryClass

CSS classes for category headings.

string $iconClass

CSS classes for icon rendering.

string $childBorderClass

CSS classes for child container border.

string|null $hoverTextClass

Hover classes for parent items (text mode).

string|null $hoverTextChildClass

Hover classes for child items (text mode).

bool $withnavigate

Whether to add wire:navigate to links.

$hideCategories
$singleOpenExpanded
$collapseButtonAsItem
$collapseButtonLabelCollapse
$collapseButtonLabelExpand
$collapseButtonIconCollapse
$collapseButtonIconExpand
$rememberCollapse
$rememberCollapseKey
$hoverMenuShowHeader
$hoverMenuHeaderClass
$hoverMenuHeaderTextClass

Methods

array
getComponentPresets(string|null $componentName = null, ComponentAttributeBag|null $attributes = null)

Compute component presets based on context.

array
loadPresets(string $componentName)

No description

array
loadComponentDefaults(string $componentName)

No description

bool
detectHasVariants(array $colors)

No description

array
computeSupports(array $sizes, array $colorsArray, array $defaults, array $magicProps)

No description

array
resolveSize(array $supports, array $sizes, array $defaults, array $magicProps)

No description

array
resolveVariant(array $supports, array $colorsArray, array $componentPresets, array $defaults, array $magicProps, bool $hasVariants)

No description

array
resolveColor(array $supports, array $colorsArray, array $componentPresets, array $defaults, array $magicProps, string|null $variant, bool $hasVariants)

No description

array
resolveFill(array $supports, array $attributes, array $defaults)

No description

string
buildCacheKey(string $component, array $supports, string|null $size, string|null $variant, string|null $color, bool $shouldFill)

No description

void
syncInstanceProps(array $supports, string|null $size, string|null $variant, string|null $color)

No description

array
buildPresetNames(array $supports, string|null $size, string|null $variant, string|null $color, bool $shouldFill, string $sizeOrigin, string $variantOrigin, string $colorOrigin, string $fillOrigin)

No description

void
debugWarnings(array $supports, array $sizePreset, array $colorPreset, string $componentName, string|null $variant, string|null $color)

No description

array
getErrorState(ComponentAttributeBag|null $attributes = null, ViewErrorBag|MessageBag|null $errors = null, string|null $error = null)

Determine the error state for a specific field.

array
getWireModelState(ComponentAttributeBag|null $attributes = null)

Analyze wire:model attributes to determine binding state.

array
getSizePreset(string|null $componentName = null, array|ComponentAttributeBag|null $attributes = null, string $defaultSize = 'md')

Resolve the size preset for the component.

__construct(mixed $items = null, string $sidebarBind = 'sidebarCollapsed', string $highlightMode = 'standard', string|null $highlightParentClass = null, string|null $highlightChildClass = null, string|null $itemClass = null, string|null $childItemClass = null, string $categoryClass = 'text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase px-3 mb-1 tracking-wide select-none', string $iconClass = '', string $childBorderClass = 'border-l border-gray-300 dark:border-gray-700', string|null $hoverTextClass = null, string|null $hoverTextChildClass = null, string $color = 'beartropy', bool $withnavigate = false, $hideCategories = false, $singleOpenExpanded = false, $collapseButtonAsItem = true, $collapseButtonLabelCollapse = null, $collapseButtonLabelExpand = null, $collapseButtonIconCollapse = 'arrows-pointing-in', $collapseButtonIconExpand = 'arrows-pointing-out', $rememberCollapse = null, $rememberCollapseKey = 'beartropy:sidebar:collapsed', $hoverMenuShowHeader = true, $hoverMenuHeaderClass = 'sticky top-0 z-10 px-3 py-2 border-b border-gray-200/80 dark:border-gray-700/70 bg-white/95 dark:bg-gray-900/95 backdrop-blur-sm', $hoverMenuHeaderTextClass = 'font-bold text-sm text-gray-700 dark:text-gray-400')

Create a new Nav component instance.

array
resolveItems(mixed $items)

Resolve the navigation items source.

array
loadConfigNav(string $nav = 'default')

Load navigation config file: config/beartropy/ui/navs/

bool
isItemActive(array $item)

Determine if a navigation item is active based on current request.

string
renderIcon(string $icon, string $iconClass = '')

Render an icon for a navigation item.

array
filterNavCategories(array $categories, mixed $user = null)

Filter navigation categories and their items based on permissions.

array
filterNavItems(array $items, mixed $user = null)

Filter a list of navigation items based on user permissions.

string
navId(array $item)

Generate a unique ID for a navigation item.

View
render()

Get the view / contents that represent the component.

Details

in HasPresets at line 21
array getComponentPresets(string|null $componentName = null, ComponentAttributeBag|null $attributes = null)

Compute component presets based on context.

Parameters

string|null $componentName

Component key.

ComponentAttributeBag|null $attributes

Attributes bag.

Return Value

array

[colorPreset, sizePreset, shouldFill, presetNames]

in HasPresets at line 59
protected array loadPresets(string $componentName)

No description

Parameters

string $componentName

Return Value

array

in HasPresets at line 73
protected array loadComponentDefaults(string $componentName)

No description

Parameters

string $componentName

Return Value

array

in HasPresets at line 88
protected bool detectHasVariants(array $colors)

No description

Parameters

array $colors

Return Value

bool

in HasPresets at line 116
protected array computeSupports(array $sizes, array $colorsArray, array $defaults, array $magicProps)

No description

Parameters

array $sizes
array $colorsArray
array $defaults
array $magicProps

Return Value

array

in HasPresets at line 137
protected array resolveSize(array $supports, array $sizes, array $defaults, array $magicProps)

No description

Parameters

array $supports
array $sizes
array $defaults
array $magicProps

Return Value

array

in HasPresets at line 174
protected array resolveVariant(array $supports, array $colorsArray, array $componentPresets, array $defaults, array $magicProps, bool $hasVariants)

No description

Parameters

array $supports
array $colorsArray
array $componentPresets
array $defaults
array $magicProps
bool $hasVariants

Return Value

array

in HasPresets at line 223
protected array resolveColor(array $supports, array $colorsArray, array $componentPresets, array $defaults, array $magicProps, string|null $variant, bool $hasVariants)

No description

Parameters

array $supports
array $colorsArray
array $componentPresets
array $defaults
array $magicProps
string|null $variant
bool $hasVariants

Return Value

array

in HasPresets at line 293
protected array resolveFill(array $supports, array $attributes, array $defaults)

No description

Parameters

array $supports
array $attributes
array $defaults

Return Value

array

in HasPresets at line 338
protected string buildCacheKey(string $component, array $supports, string|null $size, string|null $variant, string|null $color, bool $shouldFill)

No description

Parameters

string $component
array $supports
string|null $size
string|null $variant
string|null $color
bool $shouldFill

Return Value

string

in HasPresets at line 349
protected void syncInstanceProps(array $supports, string|null $size, string|null $variant, string|null $color)

No description

Parameters

array $supports
string|null $size
string|null $variant
string|null $color

Return Value

void

in HasPresets at line 365
protected array buildPresetNames(array $supports, string|null $size, string|null $variant, string|null $color, bool $shouldFill, string $sizeOrigin, string $variantOrigin, string $colorOrigin, string $fillOrigin)

No description

Parameters

array $supports
string|null $size
string|null $variant
string|null $color
bool $shouldFill
string $sizeOrigin
string $variantOrigin
string $colorOrigin
string $fillOrigin

Return Value

array

in HasPresets at line 384
protected void debugWarnings(array $supports, array $sizePreset, array $colorPreset, string $componentName, string|null $variant, string|null $color)

No description

Parameters

array $supports
array $sizePreset
array $colorPreset
string $componentName
string|null $variant
string|null $color

Return Value

void

in HasErrorBag at line 24
array getErrorState(ComponentAttributeBag|null $attributes = null, ViewErrorBag|MessageBag|null $errors = null, string|null $error = null)

Determine the error state for a specific field.

Checks both the session error bag and specific error attributes. Looks up errors by wire:model value or name attribute.

Parameters

ComponentAttributeBag|null $attributes

Component attributes.

ViewErrorBag|MessageBag|null $errors

Global error bag.

string|null $error

Specific error message override.

Return Value

array

[hasError, firstErrorMessage]

in BeartropyComponent at line 33
array getWireModelState(ComponentAttributeBag|null $attributes = null)

Analyze wire:model attributes to determine binding state.

Detects if wire:model is present and if it uses dot notation (e.g., user.name).

Parameters

ComponentAttributeBag|null $attributes

Component attributes.

Return Value

array

[hasWireModel, wireModelValue, hasDotNotation, parsedDotNotationValue]

in BeartropyComponent at line 64
array getSizePreset(string|null $componentName = null, array|ComponentAttributeBag|null $attributes = null, string $defaultSize = 'md')

Resolve the size preset for the component.

Checks:

  1. Explicit $this->size.
  2. Magic attributes (e.g., <x-button sm />).
  3. Default size.

Parameters

string|null $componentName

Component name (used for context).

array|ComponentAttributeBag|null $attributes

Attributes array or bag.

string $defaultSize

Default size key.

Return Value

array

The resolved size preset configuration.

at line 93
__construct(mixed $items = null, string $sidebarBind = 'sidebarCollapsed', string $highlightMode = 'standard', string|null $highlightParentClass = null, string|null $highlightChildClass = null, string|null $itemClass = null, string|null $childItemClass = null, string $categoryClass = 'text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase px-3 mb-1 tracking-wide select-none', string $iconClass = '', string $childBorderClass = 'border-l border-gray-300 dark:border-gray-700', string|null $hoverTextClass = null, string|null $hoverTextChildClass = null, string $color = 'beartropy', bool $withnavigate = false, $hideCategories = false, $singleOpenExpanded = false, $collapseButtonAsItem = true, $collapseButtonLabelCollapse = null, $collapseButtonLabelExpand = null, $collapseButtonIconCollapse = 'arrows-pointing-in', $collapseButtonIconExpand = 'arrows-pointing-out', $rememberCollapse = null, $rememberCollapseKey = 'beartropy:sidebar:collapsed', $hoverMenuShowHeader = true, $hoverMenuHeaderClass = 'sticky top-0 z-10 px-3 py-2 border-b border-gray-200/80 dark:border-gray-700/70 bg-white/95 dark:bg-gray-900/95 backdrop-blur-sm', $hoverMenuHeaderTextClass = 'font-bold text-sm text-gray-700 dark:text-gray-400')

Create a new Nav component instance.

Parameters

mixed $items

Array of items, or string config name.

string $sidebarBind

Sidebar bind variable.

string $highlightMode

Highlight mode.

string|null $highlightParentClass

Custom highlight parent.

string|null $highlightChildClass

Custom highlight child.

string|null $itemClass

Item class.

string|null $childItemClass

Child item class.

string $categoryClass

Category class.

string $iconClass

Icon class.

string $childBorderClass

Child border class.

string|null $hoverTextClass

Hover text class.

string|null $hoverTextChildClass

Child hover text class.

string $color

Color preset.

bool $withnavigate

Enable wire:navigate.

Blade Props

Slots

$hideCategories
$singleOpenExpanded
$collapseButtonAsItem
$collapseButtonLabelCollapse
$collapseButtonLabelExpand
$collapseButtonIconCollapse
$collapseButtonIconExpand
$rememberCollapse
$rememberCollapseKey
$hoverMenuShowHeader
$hoverMenuHeaderClass
$hoverMenuHeaderTextClass

at line 183
protected array resolveItems(mixed $items)

Resolve the navigation items source.

Parameters

mixed $items

Return Value

array

at line 206
protected array loadConfigNav(string $nav = 'default')

Load navigation config file: config/beartropy/ui/navs/

Parameters

string $nav

Return Value

array

at line 224
bool isItemActive(array $item)

Determine if a navigation item is active based on current request.

Checks path matches, route name matches, and recursive child activation.

Parameters

array $item

Return Value

bool

at line 305
string renderIcon(string $icon, string $iconClass = '')

Render an icon for a navigation item.

Parameters

string $icon

Icon name or SVG string.

string $iconClass

Extra classes.

Return Value

string

at line 326
protected array filterNavCategories(array $categories, mixed $user = null)

Filter navigation categories and their items based on permissions.

Parameters

array $categories
mixed $user

Return Value

array

at line 357
array filterNavItems(array $items, mixed $user = null)

Filter a list of navigation items based on user permissions.

Parameters

array $items
mixed $user

Return Value

array

at line 490
string navId(array $item)

Generate a unique ID for a navigation item.

Parameters

array $item

Return Value

string

at line 500
View render()

Get the view / contents that represent the component.

Return Value

View