🧒
Sunbird ED
new release -7.0.0 (Jun 2024)Askdot
release-6.0.0
release-6.0.0
  • Learn
    • Overview
    • Capabilities
      • Learning Apps
      • Asset Sourcing
      • Organised Collections
      • Discover Content - Digital & Phygital
      • User Engagement
      • Rich and diverse content
      • Versatile Question Bank
      • Observability
      • Launch Course
      • Verifiable Credentials
      • Multi-Channel Chatbot
      • Targeted Programs
      • Manage Learn
        • Overview
        • What is an entity?
        • What is a Program?
        • What is a Project?
        • What is Observation?
        • What is a Survey?
        • What is Observation as a task inside a Project?
      • Product and Developer's Guide
        • Learning apps
          • Workflows
            • Onboarding of Users
            • Discovery of Content
            • Play content
            • Track progress and Earn credentials
            • Interacting / Collaborating
        • Asset Sourcing
        • Organised Collections
        • Discover Content - Digital & Phygital
        • User Engagement
        • Rich and Diverse Content
        • Versatile Question Bank
        • Observability
        • Launch Courses
        • Verifiable Credentials
        • Multi-Channel Chatbot
        • Targeted Programs
        • Manage Learn
          • Overview
          • Component Diagram
          • ML Core Service
          • ML Project Service
          • ML Survey Service
          • ML Report Service
          • ML Analytics Service
    • Tech Overview
      • Design Principles
      • Technical Architecture Diagram
      • Tech Stack
    • Adopters
      • DIKSHA
    • Roadmap
  • USE
    • Getting started
      • Deployment Overview
      • Pre-requisites
      • Install
        • Provision Cloud Infrastructure
        • Setup Jenkins
        • Update Ansible Variables
        • Build, Provision and Deploy
        • Functional Configurations
    • Latest Release - 6.0.1
      • Release notes
      • Updating Sunbird Releases
        • 5.2.0 to 6.0.1
      • Release Calendar 6.0.1
      • Demo of released items
    • Developer Guide
      • Architecture - Component Diagram
      • System Requirements
      • Install Locally
        • SunbirdED Mobile
        • SunbirdED Portal
      • Easy Installer
      • Configuration
        • SunbirdEd Portal
        • Sunbird Mobile
      • Portal
        • Component Diagram
      • Desktop
        • Component Diagram
      • Mobile
        • Component Diagram
        • sunbird-mobile-sdk
        • Sunbird-mobile-app plugins
        • Configurations to setup mobile app
      • Form service
        • Component Diagram
        • Data model
        • API's
      • Manage Learn
        • ML Core Service
          • Overview
          • User Flow Diagram
          • Component Diagram
          • Data Model
          • Folder Structure
          • API's
          • Deployment Overview
          • Local Service Setup Guide
        • ML Project Service
          • Overview
          • User Flow Diagram
          • Component Diagram
          • Data Model
          • Folder Structure
          • API's
          • Deployment Overview
          • Local Service Setup Guide
        • ML Survey Service
          • Overview
          • User Flow Diagram
          • Component Diagram
          • Data Model
          • Folder Structure
          • API's
          • Deployment Overview
          • Local Service Setup Guide
        • ML Report Service
          • Overview
          • User Flow Diagram
          • Component Diagram
          • Data Model
          • Folder Structure
          • API's
          • Deployment Overview
          • Local Service Setup Guide
        • ML Analytics Service
          • Overview
          • Component Diagram
          • Data Model
          • Setup Guide
            • ENV Variables ( Config.ini)
          • Ingestions
          • Folder Structure
          • Report creation and Updation Scripts
          • Deployment Overview
      • UI (User interface)
        • Angular Material
          • Overview
          • Installation
          • Material Icons
          • Components Usage
          • Theming
          • Theme Setup
          • Customization
            • Palette
            • Theme
            • Accessibility
            • Colors
            • Typography
            • Components
              • Buttons
              • Card
              • Toolbar
              • Dialog
              • Menu
          • CC Components
            • Card
            • Chips
            • Expansion Panel
        • Component Style Guide Version 1
          • Accordion
          • Buttons
          • Cards
          • Forms
          • Grid & Layout
          • Labels
          • Modals
          • Pagination
          • Rating
          • Search Box
          • Select Box
          • Tables
          • Tabs
          • Toast messages
          • Tooltip
          • Typography
        • SB-Styles: A Comprehensive Design Resource
        • SB-Themes Repository: Unifying Design Across Platforms
          • Classical Theme in Sunbird-Ed portal
          • Joyful Theme in Sunbird-Ed portal:
      • Reference Apps
        • Independent Libraries
          • Common Consumption Components
          • SunbirdEd Forms
          • Sunbird Client Services
          • Sunbird Styles
          • Sunbird Themes
          • Sunbird Tag Manager
      • API's
      • Admin Dashboard Reports
      • CSP changes
      • Reports
      • Other
        • Minimal forms
        • Telemetry
          • Trackable Collection
        • Platform
        • Learning Apps
    • Learn More
      • Dependencies
      • Specifications
        • SOFIE
        • SOFIE Implementation
  • Engage
    • Discuss
    • Contribute to ED
    • Extend / Contribute to Sunbird
    • Issue tracker/ Create Issue
  • Misc
    • Templates
      • Upgrade Sunbird release document
      • Release Notes
    • Misc Pages
      • Portal - Manage Learn - Reports
      • App - Manage Learn - component diagram
        • Projects
        • Observation & Survey
        • Program
      • Portal - Manage Learn - component diagram
      • Mobile form configurations
      • Content Indexing Flow
      • What are multiple databases used for
      • Course completion, reports and certificate issue
      • How to access Flink UI
      • What are all the flink jobs for
      • How does data flow into Druid
      • Minimal build properties
    • Archived
      • High Level Capabilities
      • Workflows
      • Where Sunbird ED helps you
      • ED - Mobile App (going to archive)
        • 4.10.3 to 5.0.0
        • 5.0.0 to 5.1.0
      • Setting up Sunbird ED
      • Developer Documentation
      • API Reference Documentation
      • Detailed Documentation
      • Source Code
      • Actors & Actions
      • Detailed Capabilities
      • Data
      • Terminology
      • 5.1.0-hotfix (OCI )
Powered by GitBook
On this page
  1. USE
  2. Developer Guide
  3. UI (User interface)
  4. Angular Material
  5. Customization
  6. Components

Menu

Last updated 1 year ago

The component is used to create a menu in Angular applications following the Material Design guidelines. It typically consists of a trigger element (e.g., a button) and a hidden menu that appears when the trigger is interacted with (e.g., clicked).

Before writing code in our HTML components, we initially imported and declared the MatMenuModule in "groups.module.ts".

import {MatMenuModule} from '@angular/material/menu';

@NgModule({
  declarations: [
    // code here
  ],
  imports: [
    MatMenuModule
  ],
  exports: [
  ]
})

Here's a breakdown of the mat-menu component:

Trigger Element: The trigger element is the UI element that, when interacted with, opens the associated menu. It can be any clickable element like a button or an icon. In the example from before, the trigger element is a button with the [matMenuTriggerFor] directive pointing to the mat-menu.

group-header.component.html
<button mat-icon-button [matMenuTriggerFor]="menu" id="group-actions" tabindex="0" (click)="addTelemetry('kebab-menu')">
    <mat-icon>more_vert</mat-icon>
</button>

Menu Content: The content of the menu is defined within the <mat-menu> tags. You can include various items inside the menu, such as mat-menu-item for clickable items within the menu.

group-header.component.html
<mat-menu #menu="matMenu">
  <div *ngIf="groupData?.isAdmin">
    <div *ngIf="groupData?.active">
      <button mat-menu-item (click)="editGroup();addTelemetry('edit-group', '', { type: UPDATE_GROUP})" tabindex="0">{{resourceService?.frmelmnts?.lbl?.editGroup}}</button>
      <button mat-menu-item (click)="toggleModal(true, 'deActivate')" tabindex="0">{{resourceService?.frmelmnts?.btn?.deactivategrp}}</button>
      <button mat-menu-item (click)="enableDiscussionForum()" tabindex="0" *ngIf="forumIds.length === 0">{{resourceService?.frmelmnts?.lbl?.enableDiscussionForum}}</button>
    </div>
  </div>
  <div *ngIf="groupData?.isCreator">
    <button mat-menu-item class="color-warn" (click)="toggleModal(true, 'delete');" tabindex="0">{{resourceService?.frmelmnts?.lbl?.deleteGroup}}</button>
  </div>
</mat-menu>

Configuration: You can configure the menu by using various options. For example, you can use [xPosition] and [yPosition] to control the position of the menu, and [hasBackdrop] to specify whether clicking outside the menu should close it.

<mat-menu #menu="matMenu" [xPosition]="'before'" [yPosition]="'below'" [hasBackdrop]="false">
  <!-- menu items go here -->
</mat-menu>

The anticipated output is as follows:

Menu with custom styles

To apply custom styles, we create an HTML class named "custom-menu" and by utilizing this class, we override the existing styles.

<mat-menu #menu="matMenu" class="custom-menu"> 
    <!-- menu items go here -->
</mat-menu>
.custom-menu{
  &.mat-menu-panel {
    box-shadow: 0 0.1875rem 0.3125rem 0.25rem #0000000d;
    padding: 0.5rem;
    border-radius: 1rem;
    .mat-menu-content {
      padding: 0;
      .mat-menu-item {
        font-size: .875rem;
        height: 36px;
        line-height: 36px;
        border-radius: 1rem;
        &:hover {
            background: var(--color-primary-50);
        }
      }
    }
  }
}

And the expected result is

Remember to check the official for the latest features and detailed information.

mat-menu
Angular Material Menu documentation