Seeking ways to ensure my component maximizes available space using Tailwind CSS

I am currently utilizing Tailwind CSS to style a Angular application. The setup is fairly straightforward: app.component.html is responsible for displaying a navigation bar and footer, while the components are shown in the remaining space with an overflow-y.

However, I am encountering an issue where my component is not taking up all the available remaining space despite using w-full or flex-grow.

This is what my app.component.html looks like:

<div class="flex flex-col h-screen w-screen">
  <app-topbar></app-topbar>
    <div class="flex flex-grow overflow-y-auto mx-6 mt-6 bg-red-700">
      <router-outlet></router-outlet>
    </div>
  <app-footer/>
</div>

And here's a snippet from collection.component.html:

<div class="flex h-full w-full bg-amber-400">
  <form [formGroup]="searchForm" *ngIf="(currentBreakpoint$ | async) === Breakpoints.XSmall">
    <mat-form-field appearance="outline" class="">
      <mat-label>Name</mat-label>
      <input matInput placeholder="" [value]="searchForm.value.name" formControlName="name">
    </mat-form-field>
  </form>
  <button mat-raised-button color="primary" (click)="search()" [disabled]="searchForm.invalid">Rechercher</button>
</div>

The section highlighted in yellow denotes the collection.component.html, which should occupy all the available width. If this issue stems from undefined parent width, I'm uncertain how to address it since I cannot access the tag <collection.component />.

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

UPDATE: While using w-[calc(100vw-48px)] (100% of viewport width minus some margins) instead of w-full resolves the problem, I want to avoid relying on such calculations, as margin values may change with media queries.

Answer №1

If you wrap your app's router-outlet in the following code with flex, adding w-full will resolve the issue.

Rather than:

<div class="flex flex-grow overflow-y-auto mx-6 mt-6 bg-red-700">
  <router-outlet></router-outlet>   
</div>

Use this instead:

<div class="flex flex-grow overflow-y-auto mx-6 mt-6 bg-red-700 w-full">
  <router-outlet></router-outlet>   
</div>

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

my goal is to transform this text into the background

For my latest project, I want the entire page that I've coded to be integrated into the <body> section with endless scrolling ability. Additionally, I need the loop that I created to remain fixed when scrolling so that I can easily place my con ...

Angular CORS Policy

I encountered an issue when trying to send an authorization header JWT token from Angular. The error message reads: Access to XMLHttpRequest at 'http://localhost:52278/api/user/signup' from origin 'http://localhost:4200' has been blocke ...

Implementing an overlay feature upon clicking a menu item - here's how!

I am currently working on implementing an overlay that displays when clicking on a menu item, such as item 1, item 2 or item 3. I have managed to create a button (Click me) that shows an overlay when clicked. Now, I would like to achieve the same effect wh ...

Modifying a Component's Value in its Template Based on an IF Condition in Angular 6

How can I display or hide the 'separator-container' based on a specific condition in the row data? The condition to satisfy is mentioned as "myConditionCheck" in the 5th line of code. I attempted to achieve this by using "isWarningSeperatorVisib ...

Getting the date from an XHR header in Angular2: A step-by-step guide

Is it possible to retrieve a date from XHR Header Response? I attempted to include '{observe: 'response'}' as options constructor(private http: HttpClient) { } getAllTemps() { return this.http.get<AllTemp>(this.endp ...

Troubleshooting: Issue encountered while adding jQuery Slideshow plugin to current website

I am currently facing some challenges with a specific feature on my website. I am trying to integrate Jon Raasch's "Simple jQuery Slideshow Plugin" into an existing site that was not originally built by me. However, when viewing the site in IE 9, two ...

Is the button not aligned properly with the email input field?

<div class="subscribe__form--action--btn"> <form action="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="32545b5e5b5746545C5B5356477F54585850"> </a>" meth ...

Resize images in PHP and MySQL with precision without distorting the image

I'm looking for a solution to resize images on upload without deforming them. The current code uploads the image and stores it in the database, but I need to add resizing functionality. I'd prefer not to use JavaScript, but if necessary, please i ...

Having trouble getting your jQuery/JavaScript function to detect the property "-webkit-clip-path"?

Exploring the clip-path feature of CSS has been a fun experiment for me. I have successfully implemented it in my project and am now trying to incorporate JavaScript to dynamically change the start/stop positions of the clip-path. Below is a snippet of my ...

Is there a way to retrieve the latitude and longitude values using a plugin and then make a web service call in Ionic with Angular 5?

I am currently trying to retrieve the latitude and longitude coordinates of a location by using geocode in Angular 5 within the Ionic framework. Once I have obtained the lat long, I intend to pass it to my service. The issue I am facing is that my service ...

Rapid HTML coding dilemma

Currently, I am in the process of quickly marking up my webpage. One issue I am facing is that I would like my title to be displayed below my <nav> tag instead of beside it. Can anyone provide guidance on how to achieve this? Here is the current HT ...

Is there a way for me to choose every element excluding those contained within a specific div?

Check out my code snippet: <div class="car"> <div class="make">NISSAN</div> <div class="model">MICRA</div> </div> <div class="discontinued"> <div class="car"> <div class="make">FOR ...

Change the value of the material slide toggle according to the user's response to the JavaScript 'confirm' dialogue

I am currently working on implementing an Angular Material Slide Toggle feature. I want to display a confirmation message if the user tries to switch the toggle from true to false, ensuring they really intend to do this. If the user chooses to cancel, I&ap ...

Covering a secret link with a backdrop image

I have set a background image in a column on my WordPress site. However, I want to make this image clickable by placing a transparent box over it, as background images cannot be linked directly. #container { background-image: url(https://www.quanser.c ...

Utilizing CSS to set a map as the background or projecting an equirectangular map in the backdrop

How can I set an equirectangular projection like the one in this example http://bl.ocks.org/mbostock/3757119 as a background for only the chart above the X-axis? Alternatively, is it possible to use an image of a map as a CSS background instead? .grid . ...

The element access has been upgraded to utilize ng-content

I attempted to create a tabs component that could be used similarly to Angular Material Component. However, the solution I came up with was flawed and buggy. In this attempt, I utilized document.getElementsByTagName('app-tab'). This is the temp ...

Guide to refreshing filters once data is updated in PrimeNG tables?

Whenever I add new rows to the table, the display updates dynamically. However, any filters I have applied only reflect the initial data. https://i.stack.imgur.com/5Nuxe.png For example, if I use the "startsWith" filter on a column labeled "Title" with a ...

Configuring a server-side rendered Angular application on Plesk hosting platform

After successfully setting up server side rendering in my Angular app using nguniversal on my local machine, I am now facing the challenge of implementing this on a remote server with Plesk. In my local environment, I can serve the files by running: npm r ...

Uh-oh! An unexpected type error occurred. It seems that the property 'paginator' cannot be set

I am developing a responsive table using Angular Material. To guide me, I found this helpful example here. Here is the progress I have made so far: HTML <mat-form-field> <input matInput (keyup)="applyFilter($event.target.value)" placeholder ...

Calculating the total number of rows that are currently selected in the ag-grid

I am struggling to get an accurate count of the selected rows in my grid. It seems like onRowClicked or onRowSelected events are triggered before the row I click is actually selected. Is there a way to accurately count the number of selected rows when a r ...