PHPackages                             shopper/sidebar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. shopper/sidebar

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

shopper/sidebar
===============

A sidebar builder for Laravel

v2.6.4(2mo ago)26.9k—4.2%21MITPHPPHP ^8.3

Since Aug 22Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/shopperlabs/sidebar)[ Packagist](https://packagist.org/packages/shopper/sidebar)[ RSS](/packages/shopper-sidebar/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelogDependencies (18)Versions (57)Used By (1)

Laravel Sidebar
===============

[](#laravel-sidebar)

A headless sidebar package for Laravel that allows you to create and manage sidebars with full customization support.

Originally forked from [SpartnerNL/Laravel-Sidebar](https://github.com/SpartnerNL/Laravel-Sidebar).

Installation
------------

[](#installation)

Require this package in your project:

```
composer require shopper/sidebar
```

Publish the config file:

```
php artisan vendor:publish --provider="Shopper\Sidebar\SidebarServiceProvider" --tag="sidebar-config"
```

Publish the views (optional, for customization):

```
php artisan vendor:publish --provider="Shopper\Sidebar\SidebarServiceProvider" --tag="sidebar-views"
```

Add the middleware to your route group or `bootstrap/app.php`:

```
// In a route group
Route::middleware(['web', \Shopper\Sidebar\Middleware\ResolveSidebars::class])
    ->group(function () {
        // Your routes
    });

// Or in bootstrap/app.php (Laravel 11+)
->withMiddleware(function (Middleware $middleware) {
    $middleware->appendToGroup('web', [
        \Shopper\Sidebar\Middleware\ResolveSidebars::class,
    ]);
})
```

Configuration
-------------

[](#configuration)

The config file (`config/sidebar.php`) allows you to customize:

```
return [
    // Caching method: null, 'static', or 'user-based'
    'cache' => [
        'method' => null,
        'duration' => 1440,
    ],

    // Sidebar dimensions (CSS values)
    'width' => '16.5rem',
    'collapsed_width' => '4.5rem',

    // Responsive breakpoint (pixels)
    'breakpoint' => 1024,

    // Allow sidebar to be collapsed on desktop
    'collapsible' => true,
];
```

Creating a Sidebar
------------------

[](#creating-a-sidebar)

### 1. Create a Sidebar Class

[](#1-create-a-sidebar-class)

```
