Responsive mode in Angular Toolbar component

27 Apr 202416 minutes to read

This section explains the supported display modes of the Toolbar when the content exceeds the viewing area. Possible modes are:

  • Scrollable
  • Popup

Scrollable

The default overflow mode of the Toolbar is Scrollable. Scrollable display mode supports display of commands in a single line with horizontal scrolling enabled when commands overflow to available space.

  • The right and left navigation arrows are added to the start and end of the Toolbar to navigate to hidden commands.
  • You can also see the hidden commands using touch swipe action.
  • By default, if navigation icon in the left side is disabled, you can see the hidden commands by moving to the right.
  • By clicking the arrow or by holding the arrow continuously, hidden commands will become visible.
  • If device navigation icons are not available, you can touch swipe to see the hidden commands of the Toolbar.

Scrollable

  • Once the Toolbar reaches the last or first command, the corresponding navigation icon will be disabled and you can move to the opposite direction.

Touch scroll

Swipe scroll

  • You can continuously scroll the Toolbar content by holding the navigation icon.

Long press scroll

import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ToolbarModule } from '@syncfusion/ej2-angular-navigations'
import { TooltipModule } from '@syncfusion/ej2-angular-popups'



import { Component, ViewChild } from '@angular/core';
import { ToolbarComponent } from '@syncfusion/ej2-angular-navigations';

@Component({
imports: [
         ToolbarModule, TooltipModule
    ],


standalone: true,
    selector: 'app-container',
    template: `
        <ejs-toolbar width="300px">
          <e-items>
             <e-item text='Cut' prefixIcon = 'e-cut-icon tb-icons'></e-item>
             <e-item text='Copy' prefixIcon = 'e-copy-icon tb-icons'></e-item>
             <e-item text='Paste' prefixIcon = 'e-paste-icon tb-icons'></e-item>
             <e-item type='Separator'></e-item>
             <e-item text='bold' prefixIcon = 'e-bold-icon tb-icons'></e-item>
             <e-item text='underline' prefixIcon = 'e-underline-icon tb-icons'></e-item>
             <e-item text='italic' prefixIcon = 'e-italic-icon tb-icons'></e-item>
             <e-item type='Separator'></e-item>
             <e-item text='A-Z Sort' prefixIcon = 'e-ascending-icon tb-icons'></e-item>
             <e-item text='Z-A Sort' prefixIcon = 'e-descending-icon tb-icons'></e-item>
             <e-item text='Clear' prefixIcon = 'e-clear-icon tb-icons'></e-item>
          </e-items>
        </ejs-toolbar>
        `
})

export class AppComponent {

}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Popup is another type of overflowMode in which the Toolbar container holds the commands that can be placed in the available space. The rest of the overflowing commands that do not fit within the viewing area moves to the overflow popup container.

The commands placed in the popup can be viewed by opening the popup using the drop down icon given at the end of the Toolbar.

Toolbar popup

If the popup content overflows the height of the page, then the rest of the commands will be hidden.

Priority of commands

Default popup priority is set as none, and when the commands of the Toolbar overflow, the ones listed last will be moved to the popup.

You can customize the priority of commands to be displayed on the Toolbar and popup by using the overflow property.

Property Description
show Always shows items on the Toolbar with primary priority.
hide Always shows items in the popup with secondary priority.
none No priority display, and as per the normal order commands are moved to popup when content exceeds viewing area.

If primary priority commands also exceed available space, they are moved to the popup container at top order position and placed before the secondary priority commands.

You can maintain toolbar item on popup always by using the ‘showAlwaysInPopup’ property, and this behavior is not applicable for toolbar items with overflow property as ‘show’.

import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ToolbarModule } from '@syncfusion/ej2-angular-navigations'
import { TooltipModule } from '@syncfusion/ej2-angular-popups'



import { Component, ViewChild } from '@angular/core';
import { ToolbarComponent } from '@syncfusion/ej2-angular-navigations';

@Component({
imports: [
         ToolbarModule, TooltipModule
    ],


standalone: true,
    selector: 'app-container',
    template: `
        <ejs-toolbar overflowMode = 'Popup' width= 380>
          <e-items>
             <e-item text='Cut' prefixIcon = 'e-cut-icon tb-icons' overflow ='Show'></e-item>
             <e-item text='Copy' prefixIcon = 'e-copy-icon tb-icons' overflow ='Show'></e-item>
             <e-item text='Paste' prefixIcon = 'e-paste-icon' overflow ='Show'></e-item>
             <e-item type='Separator'></e-item>
             <e-item text='Bold' prefixIcon = 'e-bold-icon tb-icons' ></e-item>
             <e-item text='Italic' prefixIcon = 'e-italic-icon tb-icons' ></e-item>
             <e-item text='underline' prefixIcon = 'e-underline-icon tb-icons' ></e-item>
             <e-item type='Separator'></e-item>
             <e-item text='A-Z Sort' prefixIcon = 'e-ascending-icon tb-icons' overflow ='Show'></e-item>
             <e-item text='Z-A Sort' prefixIcon = 'e-descending-icon tb-icons' overflow ='Show'></e-item>
          </e-items>
        </ejs-toolbar>
        `
})

export class AppComponent {

}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Text mode for buttons

The showTextOn property is used to decide button text display area on the Toolbar, popup, or both. This is useful for customization of both text and image representation of commands.

For example, you can show icon only button on the Toolbar, and in the popup container display more information about the commands with icon and text.

Possible values are,

Property Description
Both Button Text is visible in both Toolbar and Popup.
Overflow Button Text is only visible in Popup.
Toolbar Button Text is only visible on the Toolbar.

In the following code sample, text is only visible in the popup container and not in the Toolbar container.

import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ToolbarModule } from '@syncfusion/ej2-angular-navigations'
import { TooltipModule } from '@syncfusion/ej2-angular-popups'



import { Component, ViewChild } from '@angular/core';
import { ToolbarComponent } from '@syncfusion/ej2-angular-navigations';

@Component({
imports: [
         ToolbarModule, TooltipModule
    ],


standalone: true,
    selector: 'app-container',
    template: `
        <ejs-toolbar overflowMode = 'Popup' width= 330>
          <e-items>
             <e-item text='Cut' prefixIcon = 'e-cut-icon tb-icons' overflow ='Show' showTextOn = 'overflow'></e-item>
             <e-item text='Copy' prefixIcon = 'e-copy-icon tb-icons' overflow ='Show' showTextOn = 'overflow'></e-item>
             <e-item text='Paste' prefixIcon = 'e-paste-icon tb-icons' overflow ='Show' showTextOn = 'overflow'></e-item>
             <e-item type='Separator'></e-item>
             <e-item text='bold' prefixIcon = 'e-bold-icon tb-icons' overflow ='Show' showTextOn = 'overflow' ></e-item>
             <e-item text='underline' prefixIcon = 'e-underline-icon tb-icons' overflow ='Show' showTextOn = 'overflow' ></e-item>
             <e-item text='italic' prefixIcon = 'e-italic-icon tb-icons' overflow ='Show' showTextOn = 'overflow' ></e-item>
             <e-item text='Color-Picker' prefixIcon = 'e-color-icon tb-icons' overflow ='Hide' showTextOn = 'overflow' ></e-item>
             <e-item type='Separator'></e-item>
             <e-item text='A-Z Sort' prefixIcon = 'e-ascending-icon tb-icons' overflow ='Show' showTextOn = 'overflow'></e-item>
             <e-item text='Z-A Sort' prefixIcon = 'e-descending-icon tb-icons' overflow ='Show' showTextOn = 'overflow'></e-item>
             <e-item text='Clear' prefixIcon = 'e-clear-icon tb-icons' overflow ='Show' showTextOn = 'overflow'></e-item>
          </e-items>
        </ejs-toolbar>
        `
})

export class AppComponent {
  
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Render toolbar with a less than minimum height

By default, the toolbar renders with a minimum height to render items properly. You can also render a customized toolbar with a height that is less than the minimum height of the toolbar by overriding default styles from the application end.

<div class="control-section e-tbar-section">
  <div class="e-sample-resize-container">
    <h3>Scrollable mode </h3>
    <!-- Render the Toolbar Component -->
    <ejs-toolbar height="20px" width="300px">
      <e-items>
        <e-item text='Cut' prefixIcon='e-icons e-cut'></e-item>
        <e-item text='Copy' prefixIcon='e-icons e-copy'></e-item>
        <e-item text='Paste' prefixIcon='e-icons e-paste'></e-item>
        <e-item type='Separator'></e-item>
        <e-item text='bold' prefixIcon='e-icons e-bold'></e-item>
        <e-item text='underline' prefixIcon='e-icons e-underline'></e-item>
        <e-item text='italic' prefixIcon='e-icons e-italic'></e-item>
        <e-item type='Separator'></e-item>
        <e-item text='Export' prefixIcon='e-icons e-export'></e-item>
        <e-item text='Reload' prefixIcon='e-icons e-refresh'></e-item>
        <e-item text='Clear' prefixIcon='e-icons e-erase'></e-item>
      </e-items>
    </ejs-toolbar>
    <br>

    <h3>Popup mode </h3>
    <!-- Render the Toolbar Component -->
    <ejs-toolbar height="20px" overflowMode='Popup' width='380px'>
      <e-items>
        <e-item text='Cut' prefixIcon='e-icons e-cut' overflow='Show' showTextOn='overflow'></e-item>
        <e-item text='Copy' prefixIcon='e-icons e-copy' overflow='Show' showTextOn='overflow'></e-item>
        <e-item text='Paste' prefixIcon='e-icons e-paste' overflow='Show' showTextOn='overflow'></e-item>
        <e-item type='Separator'></e-item>
        <e-item text='bold' prefixIcon='e-icons e-bold' overflow='Show' showTextOn='overflow'></e-item>
        <e-item text='underline' prefixIcon='e-icons e-underline' overflow='Show' showTextOn='overflow'></e-item>
        <e-item text='italic' prefixIcon='e-icons e-italic' overflow='Show' showTextOn='overflow'></e-item>
        <e-item text='Color-Picker' prefixIcon='e-icons e-paint-bucket' overflow='Hide' showTextOn='overflow'></e-item>
        <e-item type='Separator'></e-item>
        <e-item text='Export' prefixIcon='e-icons e-export' overflow='Show' showTextOn='overflow'></e-item>
        <e-item text='Reload' prefixIcon='e-icons e-refresh' overflow='Show' showTextOn='overflow'></e-item>
        <e-item text='Clear' prefixIcon='e-icons e-erase' overflow='Show' showTextOn='overflow'></e-item>
      </e-items>
    </ejs-toolbar>
  </div>
</div>
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ToolbarModule } from '@syncfusion/ej2-angular-navigations'




import { Component, ViewEncapsulation } from '@angular/core';
import { ToolbarComponent } from '@syncfusion/ej2-angular-navigations';

@Component({
imports: [
         ToolbarModule
    ],


standalone: true,
    selector: 'app-container',
    templateUrl: './app.component.html',
    encapsulation: ViewEncapsulation.None
})
export class AppComponent {
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));