Looking for an Angular Material component that displays a list of attributes?

I am trying to create a dynamic list of properties in Angular using Material Design that adjusts for different screen sizes.

For example, something similar to this design:

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

If the screen size decreases, the labels should shift above their corresponding values.

While I could develop something on my own, I believe this is a common issue. What is the recommended way to display this using Material Design and Angular?

Answer №1

After some trial and error, I managed to complete the task on my own. I decided to utilize a DL definition list as it aligns perfectly with the key-value pair structure using DT for type and DD for details.

Regarding the CSS (included in my SCSS), the essential concept involves utilizing a grid system along with grid-column-start

DL {
  font-family: "Roboto", Arial, sans-serif;
  display: grid;
  grid-template-columns: max-content auto;
  padding-left: 24px;
}

DT {
  color: #777;
  display: inline-block;
  grid-column-start: 1;
  padding: 2px 20px 10px 0px;
  margin: 0px;
  @include text-extra-small($color-grey-600);
}

DD {
  display: inline-block;
  grid-column-start: 2;
  font-size: 16px;
  color: #333;
  margin: 0px;
  padding: 0px 0px 10px;
  @include text-body($color-grey-800);

}
@include for-mobile {
  DD {
    grid-column-start: 1;
  }
}

https://i.stack.imgur.com/55sRU.png

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

Dealing with a multi-part Response body in Angular

When working with Angular, I encountered an issue where the application was not handling multipart response bodies correctly. It seems that the HttpClient in Angular is unable to parse multipart response bodies accurately, as discussed in this GitHub issue ...

What steps can be taken to hide empty items in a list from being shown?

When I map over an array of books to display the titles in a list, I encounter an issue with the initial empty string value for the title. This causes the list to render an empty item initially. Below is my book array: @observable books = [ {title:" ...

When should CSS compression and combining / JS minification be performed - at runtime or during build time?

I need to find a way to compress, version (for caching reasons), and possibly combine our JS and CSS files. I've come across two main approaches so far: 1) During the build process: Using an MSBuild task or similar. 2) Dynamically at runtime: Through ...

Eliminate the mystery overflow in your CSS styling

My website is experiencing overflow on the x axis, even though all vw/width properties are set to 100. I suspect that the .logout element may be causing this issue, but I'm not sure what exactly needs to be modified to resolve it. Any assistance would ...

The Twitter widget is not staying in sync with the rest of the page when scrolling on

Twitter provides a widget that is widely used by many people. Below is the code provided by Twitter: <script src="http://widgets.twimg.com/j/2/widget.js"></script> <script> new TWTR.Widget({ version: 2, type: 'profile', ...

The Angular directive needed to support the GoogleSigninButtonDirective in the @abacritt/[email protected] package is currently incompatible with Angular 13

Despite the documentation declaring that @abacritt/angularx-social-login:1 is compatible with Angular 13 and 14, it fails to work in my Angular 13 project. The error arises after running npm start, pointing fingers at GoogleSigninButtonDirective for the is ...

Using rxjs takeUntil will prevent the execution of finalize

I am implementing a countdown functionality with the following code: userClick=new Subject() resetCountdown(){this.userClick.next()} setCountDown() { let counter = 5; let tick = 1000; this.countDown = timer(0, tick) .pipe( take(cou ...

At what point does the constructor of an injected service in Angular execute?

When using @Injectable({providedIn: 'root'}) in Angular 7 for a service, the constructor of the service executes when exactly? Is it upon the creation of a component that utilizes it as a dependency or does it wait until a method within the servi ...

What is the best way to vertically center text within a selection box? (This is not referring to a select box or a div box)

While assigning a line-height to text elements like div, span, or p and dragging them in the browser, an unsightly empty space appears within the selection box: I am seeking a way to elevate the actual text content within the selection box to enhance its ...

What is the most effective way to perform unit testing on the "present" function of an Ionic alert controller?

I decided to write a unit test for the alert present function that gets triggered after creating an alert. This is what my code looks like. it('should call attempt To call alert present', async () => { const alert = { header: 'P ...

Module for migration located in a subdirectory

Currently, I am in the process of transitioning an Angular application to NativeScript while utilizing a code-sharing setup. For the migration of Angular modules, I have been executing the following command: ng g migrate-module --name=nameModule However ...

How can I turn off Angular Grid's virtualization feature, where Angular generates div elements for the grid based on height and width positions?

Currently, I am working with an Angular grid (ag-grid) that dynamically creates div elements in the DOM to display data as the user scrolls or views different sections. As part of my testing process using Selenium WebDriver, I need to retrieve this data fr ...

What is the source of Docker's node version information?

Within the Dockerfile, I specified the version node:14.17.6-alpine3.13. However, in the deployment log, it shows a different version, node:16.13.2-alpine. Can anyone shed light on why this discrepancy exists and how to rectify it? docker-compose deploy lo ...

"Integrating backgrounds into divs disrupts the overall design aesthetic

One of the challenges I faced was trying to space out the three columns in my Bootstrap row while also splitting each column into two parts. After doing some research, here's the solution I came up with: <div class="container row h-100 mx-auto ...

Having difficulty with setting up the Webpack css-loader, encountering an error during compilation

As a newcomer to webpack, I have been experimenting with creating my own build by modifying an existing one. One issue I encountered was the css not compiling, so I took the following steps: Confirmed that there were no css loaders already included in th ...

Converting a string to a date type within a dynamically generated mat-table

I am working on a mat-table that shows columns for Date, Before Time Period, and After Time Period. Here is the HTML code for it: <ng-container matColumnDef="{{ column }}" *ngFor="let column of columnsToDisplay" > ...

Access a designated tab within a CSS-designed tab system

Can anyone offer some assistance? I currently have a tab structure created using CSS. The first tab is set as the default when the page loads. I am looking to create a link from another page that will take users directly to the page with the tabs and ope ...

Only one radio button in Angular2 remains enabled

On a page, I have a set of radio buttons grouped into "Yes" or "No" buttons. Depending on the value of a variable, I want to disable them. However, only the "Yes" button is disabled when initially loading the page. There is also a drop-down that changes ...

Tailwind custom classes are not being rendered on mobile devices and Chrome DevTools, however, they are functioning properly on desktops and Safari DevTools

During the development of my project using Tailwind CSS, I focused on desktop compatibility and ensured responsiveness with Safari and Google Chrome. However, upon switching to DevTools, I encountered issues that persisted when testing on mobile devices. ...

Using the Async feature, I can retrieve the value of a string type when the return type of a function is Promise<any>

While working on a custom pipe, I encountered a situation that puzzled me. Can you explain why the code snippet below is considered valid? async transform(value: any): Promise<string> { let fullNameBasedOnPreference: string; fullNameBasedOnP ...