ebess / nova-collapsible-sidebar by ebess

A collapsible sidebar for Laravel Nova.
283,739
32
2
Package Data
Maintainer Username: ebess
Package Create Date: 2018-10-02
Package Last Update: 2022-12-08
Language: Vue
License: MIT
Last Refreshed: 2024-11-18 03:01:03
Package Statistics
Total Downloads: 283,739
Monthly Downloads: 2,053
Daily Downloads: 10
Total Stars: 32
Total Watchers: 2
Total Forks: 4
Total Open Issues: 19

Collapsible sidebar for laravel nova

This package provide you with a collapsible sidebar for the laravel nova admin panel.

Sidebar

Installation

composer require ebess/nova-collapsible-sidebar

In order to extend the default sidebar you need to export the layout of nova.

mkdir -p resources/views/vendor/nova
cp -r vendor/laravel/nova/resources/views/layout.blade.php resources/views/vendor/nova/layout.blade.php

In resources/views/vendor/nova/layout.blade.php you will find the sidebar which looks something like this.

<!-- Sidebar -->
<div class="min-h-screen flex-none pt-header min-h-screen w-sidebar bg-grad-sidebar px-6">
    <a href="{{ Nova::path() }}">
        <div class="absolute pin-t pin-l pin-r bg-logo flex items-center w-sidebar h-header px-6 text-white">
           @include('nova::partials.logo')
        </div>
    </a>

    @foreach (Nova::availableTools(request()) as $tool)
        {!! $tool->renderNavigation() !!}
    @endforeach
</div>

Replace the ordinary div tag by collapsible-sidebar.

<collapsible-sidebar class="min-h-screen flex-none pt-header min-h-screen w-sidebar bg-grad-sidebar px-6">
    <!-- -->
</collapsible-sidebar>

That's it! Now you can toggle the sidebar by clicking the icon. By default you can use Esc to toggle it as well.

Also there are several other options you can configure.

Will save the collapsed status to local storage:

<collapsible-sidebar class="..." persist>    
    <!-- -->
</collapsible-sidebar>

Now you can toggle it by pressing F2 instead of Esc:

<collapsible-sidebar class="..." toggle-key-code="F2">    
    <!-- -->
</collapsible-sidebar>