Navigation side-panel
All controllers

Side Panel

Controls an inline panel's expanded state, accessibility attributes, and cookie persistence.

Identifier: side-panel Loaded by: auto-loaded after php artisan hotwire:install; publish only to customize with php artisan hotwire:controllers side-panel.

Requirements

  • No external dependencies.

Basic Usage

HTML
<div
    data-controller="side-panel"
    data-side-panel-name-value="project-navigation"
    data-side-panel-open-value="true"
    data-side-panel-cookie-name-value="side_panel_project-navigation_state"
    data-action="turbo:before-render@window->side-panel#preserveStateForRender"
    data-state="expanded"
>
    <aside id="project-navigation-panel" data-side-panel-target="panel">
        Navigation
    </aside>

    <button
        type="button"
        data-side-panel-target="trigger"
        data-action="side-panel#toggle"
        aria-controls="project-navigation-panel"
        aria-expanded="true"
    >
        Toggle
    </button>
</div>

The controller synchronizes root data-state, trigger aria-expanded, and panel inert. When persist is enabled and cookieName is present, state changes write a cookie; preserveStateForRender copies the current state into Turbo's next body render.

State and accessibility attributes update immediately; the controller does not wait for visual motion. Presets can tune the complete transition system through the custom properties documented by the side-panel component without changing controller lifecycle.

Values

Value Type Default Description
open boolean true Current expanded state.
persist boolean true Whether changes write a cookie.
name string none Stable identity used to match Turbo renders.
cookieName string none Cookie written when persistence is enabled.

Persistence is a no-op when cookieName is absent. The Blade component always supplies a name derived from its required name prop.

Targets

Target Description
panel Receives inert while collapsed.
trigger Receives synchronized aria-expanded.

Stimulus excludes targets owned by nested instances of the same controller. This makes nested Side Panels independent without document-wide selectors or instance ids.

Actions

Action Description
toggle Toggle expanded/collapsed state.
open Expand the panel.
close Collapse the panel.
preserveStateForRender Copy current state into Turbo's next body pre-render.

Events

Changes dispatch <identifier>:change; the default identifier emits side-panel:change:

JS
{ open: boolean, state: "expanded" | "collapsed" }

Standalone Usage

HTML
<div
    data-controller="side-panel"
    data-side-panel-name-value="project-navigation"
    data-side-panel-open-value="true"
    data-side-panel-cookie-name-value="side_panel_project-navigation_state"
    data-state="expanded"
>
    <aside id="project-navigation-panel" data-side-panel-target="panel">Navigation</aside>

    <button
        type="button"
        data-side-panel-target="trigger"
        data-action="side-panel#toggle"
        aria-controls="project-navigation-panel"
        aria-expanded="true"
    >
        Toggle
    </button>
</div>