Difficulty Aligning Angular Material Expansion Panel with mat-nav-listI am facing an issue with

Currently, I have implemented a mat-nav-list to showcase the Menu items on my webpage. However, there seems to be an alignment issue with the 4th Menu item which is an Angular Material Expansion control. Refer to the screenshot provided below for clarification.

UPDATED INFORMATION

You can find the relevant code snippet below..

I need assistance in aligning the Icon to the left side of the Menu list. How can this be corrected?

Answer №1

I encountered an issue while attempting to replicate the error:

https://i.stack.imgur.com/BJ6t5.png

The challenge stemmed from the following factors:

  1. The default padding: 0 24px; for the mat-expansion-panel-header element was conflicting with the padding: 0 16px; set for the mat-list-item element.
  2. You forgot to include the border-collapse: collapse; CSS property for the table.

Additionally, update

<table border="1" width="200px">
to
<table border="0" width="200px>
.


list-overview-example.ts

import { Component } from '@angular/core';
import { MatListModule } from '@angular/material/list';
import { MatIconModule } from '@angular/material/icon';
import { MatExpansionModule } from '@angular/material/expansion';

/**
 * @title Basic list
 */
@Component({
  selector: 'list-overview-example',
  templateUrl: 'list-overview-example.html',
  standalone: true,
  imports: [MatListModule, MatIconModule, MatExpansionModule],
})
export class ListOverviewExample {}

list-overview-example.html

<mat-list role="list">
  <a mat-list-item role="listitem">
    <mat-icon>accessibility</mat-icon>
    <span>User 1</span>
  </a>
  <a mat-list-item role="listitem">
    <mat-icon>accessibility</mat-icon>
    <span>User 2</span>
  </a>
  <a mat-list-item role="listitem">
    <mat-icon>accessibility</mat-icon>
    <span>User 3</span>
  </a>
  <a>
    <mat-accordion class="mat-accordion-setting">
      <mat-expansion-panel hideToggle>
        <mat-expansion-panel-header>
          <mat-panel-title matTooltip="User 4 Title" style="text-align: left">
            <table border="0" width="200px">
              <tr>
                <td style="padding-left: 0px; padding-right: 0px">
                  <mat-icon class="mat-accordion-setting">accessibility</mat-icon>
                </td>
                <td class="mat-panel-title-setting">User 4 Title</td>
              </tr>
            </table>
          </mat-panel-title>
        </mat-expansion-panel-header>
        <div>
          <mat-panel-description id="submenu1" class="mat-panel-description-setting"><a>Submenu 1</a></mat-panel-description>
          <mat-panel-description id="submenu2" class="mat-panel-description-setting"><a>Submenu 2</a></mat-panel-description>
          <mat-panel-description id="submenu3" class="mat-panel-description-setting"><a>Submenu 3 </a></mat-panel-description>
        </div>
      </mat-expansion-panel>
    </mat-accordion>
  </a>
</mat-list>

styles.scss

.mat-expansion-panel-header {
  padding: 0 16px !important;
}

table {
  border-collapse: collapse;
}

Output:

https://i.stack.imgur.com/uAD8x.png

Check out the live demo.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Display various images based on different device orientations in UIWebView

Is there a way to display varying images in my HTML on a UIWebView, depending on the orientation of an iPhone? (I apologize if this question seems basic...) ...

Chrome not handling text wrapping within table cells properly

I'm facing an issue with a table I created using the bootstrap stylesheet. For some reason, the cells are not wrapping correctly in Chrome, although they display perfectly fine in IE and Firefox. You can check it out here: <form action="todos" m ...

Is it possible to pass a number instead of a string to Angular's matToolTip within a mat-icon-button? If not, is there a way to convert the number to a string within an Angular

In my current situation, I am facing a challenge with the following line of code: [matTooltip]="ratingId + 1". This line is crucial as it forms part of the arguments for a Material Design button. However, in this case, things are not straightfo ...

Utilizing the RxJs map operator to update the attributes of multiple objects within an Angular collection

Inside my angular component, I have the following properties: memberInfoLists$: Observable<MemberInfo[]>; total$: Observable<number>; memberPhotoUrl: string = environment.memberPhotoUrl; memberDefaultPhoto: string = environment.defaultPersonPho ...

The CanActivate route guard in Angular Router never seems to return a true value

I'm facing an issue with using CanActivate to protect a page, as it always returns false and I can't access the protected router. Despite trying various solutions, I haven't been able to resolve the problem yet. Being new to angular, I' ...

Harnessing the power of JavaScript functions to display an image when clicked

Looking for help with making an image appear when clicking on one of three images? Despite trying different approaches, the desired result is still not achieved. I'm aware of using if else statements but exploring other methods. Any insights on what m ...

To implement a class based on a media query, only pure CSS or HTML is required

Is there a way to apply a specific class to an ID based on screen height using only CSS, HTML, or LESS without pre-compilation? The goal is to set classes from Add2Any, not CSS properties. Here is a link to the jsfiddle. The desired outcome is to have th ...

Create a slider feature on a webpage using the Google Maps API

A webpage has been created using the Google Map API. JSfiddle function initMap() { var intervalForAnimation; var count = 0; var map = new google.maps.Map(document.getElementById('map'), { cen ...

Using ngFor to loop through an array of objects and calculate the number of elements in an array property

Currently I am developing a web application using Angular 6. The data is obtained in the form of an array of objects from Firebase, and my intention is to present this information to the user by utilizing ngFor. export interface Competition { createdAt: ...

Can Vue.js 3 composition be leveraged with v-for to incorporate a query string into a router-link?

I have successfully implemented v-for for a URL path. Now, I am looking to merge the URL path with the query string in the router link tag. The query string will be the date from each item rendered by v-for. Is there a way to dynamically pass this query ...

Line of cubes - tap on a single cube and the others gracefully slide away from view

I am working on a project where I need to create a row of blocks. The goal is for the blocks to slide off the screen when one is clicked, leaving the clicked block in the first position. For instance: https://i.sstatic.net/IB5LI.jpg I attempted using jQ ...

Issue: npm encountered an error due to writing after reaching the end

I've encountered a problem while trying to install Cordova and Ionic. Due to what appears to be a corrupted installation, I had to uninstall NodeJS - Cordova - Ionic. After re-installing NodeJS successfully, the trouble began when running the pop ...

Troubleshoot Angular2 modules efficiently using source mapping features

Is there a way to debug Angular2 module code using TypeScript source mapping in the browser? After installing my project with the "npm install" command following the steps in https://angular.io/guide/quickstart, I noticed that while source mapping is ava ...

Prevent the overlap of text by controlling the positioning of a div element

Below is a simplified version of the layout I'm working with: <div style="position: relative; width:600px;"> <p>Content with unknown length, but very lengthy</p> <div>Content with unknown height</div&g ...

The unique GopikaTwo Gujarati font is unfortunately not compatible with Android mobile browsers and hybrid applications

I am currently trying to incorporate the custom font GopikaTwo into my hybrid application. Below is the code snippet I have added to my CSS file: @font-face { font-family: 'GopikaTwo' !important; src: url('GopikaTwo.eot') !impo ...

Imitate a HTTP request

Currently, I am working on developing a front-end application using Angular (although not crucial to this question). I have a service set up that currently supplies hard-coded JSON data. import { Injectable } from '@angular/core'; import { Obser ...

Is it possible for an Interface's property to be a type that contains an array?

As I dive into the Angular code, I encountered a peculiar type for a property within an Interface named 'Origin' that has left me perplexed. Here's the snippet: export interface Origin { areaNum?: number; open?: { [key: stri ...

I was able to use the formGroup without any issues before, but now I'm encountering an error

<div class="col-md-4"> <form [formGroup]="uploadForm" (ngSubmit)="onSubmit(uploadForm.organization)"> <fieldset class="form-group"> <label class="control-label" for="email"> <h6 class="text-s ...

Chrome clip-path creates a white horizontal line shape that resembles a paperclip

Having an issue with horizontal white lines appearing through a div with clip-path set and background image in Chrome. Any suggestions on how to fix this? Check out the screenshot for reference: Screenshot showing the horizontal white line bug If you nee ...

Stylish News Carousel using CSS and HTML

I've been working on creating a news slider for my website, but I'm encountering an issue. Despite completing the HTML and CSS, I'm struggling to make the 'showcase' rotate using JQuery. I've tried various guides and instructi ...