Skip to main content
This guide covers how to install and use the sidebar package in a standalone Laravel application (without Shopper).

Installation

Install the package via Composer:
Publish the configuration file:
Optionally, publish the views for customization:

Setting Up the Middleware

Add the sidebar resolver middleware to your route group or in bootstrap/app.php:
Or in Laravel 11+ with bootstrap/app.php:

Creating a Sidebar

1. Create a Sidebar Class

Create a class that implements the Sidebar contract:

2. Register the Sidebar

Register your sidebar in a service provider using the SidebarManager:
Don’t forget to register the service provider in config/app.php or bootstrap/providers.php.

Using the Sidebar

Option 1: Livewire Component

The easiest way to use the sidebar is with the built-in Livewire component:

Option 2: Custom Blade Implementation

For full control, use the SidebarRenderer directly:

Alpine.js Store Setup

The sidebar uses an Alpine.js store for state management. Add the store to your JavaScript:
To get the source JavaScript files, publish them:
This will publish the files to resources/js/vendor/sidebar/.

Store API

The sidebar store provides these properties and methods: State properties: Sidebar visibility (mobile):
Sidebar collapse (desktop):
Group management:
Navigation tracking (for SPA):

CSS Variables

Add CSS variables to your layout for sidebar dimensions:

Basic Item Options

Adding Badges

Adding Append Elements

Append elements are additional action buttons displayed next to the item:

Sub-Items

Group API

Helper Functions

The package provides namespaced helper functions: