Angular Sliding Side Panel Toggle

In this post I am going to share simple angular component to add sliding panel in your angular app, On clicking on button a cool sliding panel will open where you can place any link, message or anything you want. It is An Angular library for creating beautiful, dynamic panels.

alt text


An npm package is available:

npm install @verizon/ngx-panels


Quick start

Import PanelModule.forRoot() in the module that hosts the panel container. Every other module con import it with just PanelModule (without forRoot call).
As extra steps you need to import BrowserAnimationsModule and define as entryComponents any components that will be hosted inside the panels, such as SampleComponent in this example.


    declarations: [AppComponent, SampleComponent],
    imports: [BrowserModule, BrowserAnimationsModule, PanelModule.forRoot()],
    providers: [],
    entryComponents: [SampleComponent],
    bootstrap: [AppComponent]
export class AppModule {}

In the HTML just use ngx-panel-container element. This will be the holder of all the panels.


<!-- your app -->

You should place this container inside an HTML element which has some space in it.

Whenever you need, open a Panel using the panel service. You can do this in every part of your Angular application by injecting the service.


// ...
export class AppComponent {
    constructor(private readonly panelService: PanelService) { }

    yourFunction() {;


You can specify where the panels should be opened: on the left, the right, the top or the bottom, and even a floating one which is like a modal with an overlay.
Also you can set the dimension in pixels. In order to do this, just import the panel module using some parameters in forRoot method.

    PanelModule.forRoot({ side: PanelSide.LEFT, size: 600 })

Possible values of PanelSide are PanelSide.RIGHT (default value), PanelSide.LEFT, PanelSide.TOP, PanelSide.BOTTOM and PanelSide.FLOATING

Stacking panels

You can either open a panel on top of the previously opened ones (if any), stacking them;
    // Open a second panel on top of the first one;

or you can open one replacing all the others, as “root”

    // Remove all previous panels and open a new one

Panel content

You can prepare any Angular Component to fill the panel content, but there are some sub-components that you can conveniently use to construct the panel.

<ngx-panel-header> Angular HTML content for header </ngx-panel-header>
<ngx-panel-body> Angular HTML content for body </ngx-panel-body>
<ngx-panel-footer> Angular HTML content for footer </ngx-panel-footer>

The header component already provides a close button.

Programmatically close a panel

Inside the hosted component you can access the panel reference PanelRef, that can be used to close and perform other actions programmatically.

// ...
export class SampleComponent {
    constructor(private readonly panelRef: PanelRef<any>) { }

    // Close programmatically whenever you want with the PanelRef instance
    yourFunction() {

Set initial data

When you open a panel you can send custom data that can be used as initial seed for the panel content., 'Hello world'); // openAsRoot offers the same possibility

This data can be retrieved inside the transcluded (SampleComponent) component.

/// ...
export class SampleComponent {
    constructor(private readonly panelRef: PanelRef<string>) { }

    ngOnInit() {
        // Data can be accessed anywhere in the component
        console.log(; // Prints 'Hello world'

See live demo and download source code.


This awesome script developed by verizonconnect, Visit their official github repository for more information and follow for future updates.

Don’t forget to Subscribe My Public Notebook for more useful free scripts, tutorials and articles.