Angular 14: Exploring the left datepicker panel navigation in PrimeNG

In my situation, I am trying to adjust the position of the date-picker in relation to a panel displayed within a <p-calendar> element. Due to a splitter on the right side, I need to shift the date-picker towards the left.

Here is the HTML code:

<div class="col-12">
              <div class="p-grid">
                <div class="col-6 mt-5" style="margin-left:-2%;">
                  <div class="form-input p-float-label">
                    <p-calendar inputId="fromDate" dateFormat="dd/mm/yy" [showTime]="true"
                      [maxDate]="form.get('toDate').value" [readonlyInput]="true" [monthNavigator]="true"
                      [yearNavigator]="true" yearRange="2020:{{ currentYear }}" [locale]="locale"
                      formControlName="fromDate">
                    </p-calendar>
                    <label for="fromDate">{{ 'devices.general.from' | translate }}</label>
                  </div>
                </div>
                <div class="col-6 mt-5 mb-4">
                  <div class="form-input p-float-label">
                    <p-calendar inputId="toDate" dateFormat="dd/mm/yy" [showTime]="true" class="moveToLeft"
                      [minDate]="form.get('fromDate').value" [readonlyInput]="true" [monthNavigator]="true"
                      [yearNavigator]="true" yearRange="2020:{{ currentYear }}" [locale]="locale" formControlName="toDate">
                    </p-calendar>
                    <label for="toDate">{{ 'devices.general.to' | translate }}</label>
                  </div>
                </div>
              </div>
            </div>

I attempted to use a class="moveToLeft" to address this issue, but unfortunately, it was not successful.

Upon inspecting with F12, I noticed that the left property required modification:

<div class="ng-trigger ng-trigger-overlayAnimation ng-tns-c194-50 p-datepicker p-component ng-star-inserted" ng-reflect-ng-class="[object Object]" pr_id_13="" style="z-index: 1001; transform-origin: center top; top: 32px; left: 0px;">
<div class="p-datepicker-group-container ng-tns-c194-50 ng-star-inserted" style="">
<div class="p-datepicker-group ng-tns-c194-50 ng-star-inserted">
<div class="p-datepicker-header ng-tns-c194-50"><button type="button" pripple="" class="p-ripple p-element p-datepicker-prev p-link ng-tns-c194-50 ng-star-inserted">

The reference pr_id_13 corresponds to the "To" <p-calendar>.

Lastly, my attempt in CSS to resolve this matter applied changes to both date-pickers which was not intended:

:host ::ng-deep .p-datepicker{
  left: -188px !important;
}

Answer №1

A strategy that has proven effective for me is to consider implementing the following steps.

include styleClass="yourClass"

Step 1: Design:

<p-calendar styleClass="yourClass" inputId="basic" [(ngModel)]="date1"></p-calendar>

Step 2: Styling:

:host ::ng-deep .myClass .p-datepicker {
 left: -188px !important;
}

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

Angular 2 Validation Customizer

Recently, I created a web API function that takes a username input from a text field and checks if it is already taken. The server response returns Y if the username is available and N if it's not. For validating the username, I implemented a Validat ...

Issue with Ng test: The type definition file for '@angular/localize' cannot be located

When upgrading from Angular 14 to 17, I ran into an issue with the ng test command. It seems to be malfunctioning now. Error: PS C:\ForAngular17\src\ng\cat-ng> ng test One or more browsers configured in the project's Browsersli ...

The presence of the target tag remains unchanged when a media query is used

Hello, I have a question regarding a specific issue in my code. I am trying to use a media query to make a tag disappear when the width of the window is less than 1200px, but it's not working as expected. I believe it might be related to inheritance. ...

Exploring Architectural Designs in Angular2: Redux, Flux, Reactivity, RxJS, Ngrx, MVI, and More

Isn't it annoying how all these library and framework names start with R/N or sound so similar? react/redux | flux | ngrx | @ngrx/store | RxJS/ReactiveX | MVI | .... Can anyone make sense of this chaos? I'm trying to understand, please help me ...

CSS Only Sidebar Dropdown (without using Bootstrap)

I want to create a sidebar with collapsible dropdown options and smooth animations using only pure css/js/html/jquery, without relying on bootstrap like I did in the past. Here is an example of what I created previously with bootstrap: Now, as a challenge ...

Mobile devices offer a seamless vertical scrolling experience

Here is the HTML structure I am working with: <div> <a>..</a> <i>..</i> <a>..</a> <i>..</i> <a>..</a> <i>..</i> </div> On larger screens, all elements are dis ...

What is the best method to determine the accurate height of a window that works across all browsers and platforms?

Is there a way to accurately determine the visible height of the browser window, taking into consideration any floating navigation bars or bottom buttons that may interfere with the actual viewing area? For example, mobile browsers often have floating bar ...

Angular compilation alerted about a missing export: "ɵɵdefineInjectable was not located within '@angular/core'

I'm having an issue while trying to run my Angular application. The error message related to the "ngx-mqtt": "^6.6.0" dependency keeps popping up even though I have tried changing the versions multiple times. I am using CLI 6.2.9 and cannot seem to re ...

Redirecting a CSS link on a website

I have a webpage with a "read more" option that redirects to the About Us page. When I click on "read more", the About Us page opens at the top, but I want it to redirect to the bottom of the About Us page. How can I achieve this? ...

Unable to maintain the height of a div at 100% as it keeps reverting back to 0px

I'm having trouble setting the height of the individual parent columns (and their children) to 100% because for some reason, the div height keeps resetting to 0. The first column contains two child boxes that should each take up 50% of the page heigh ...

Should we use fakeAsync() or done() to handle asynchronous tasks

When creating an Angular test with Jest and dealing with asynchronous operations, do you have a preference for how to handle it? it('', fakeAsync(() => { // test code here })); or would you rather use something like it('' ...

Why isn't the main body of CSS extending across the entire page?

I feel like I'm running headfirst into a wall trying to figure out why the code I wrote for this specific website isn't quite working properly. The main content area of my pages (the white space in the link below) is supposed to extend from the ...

Iterate through each item in an object using Angular

I attempted to utilize a forEach loop, but it's indicating that it's undefined for some reason. Here is my code snippet: var array: MoneyDTO[] = prices array.forEach(function (money: MoneyDTO) { if (money.currency == 'QTW& ...

"Accessing and updating the current navigation state using jQuery/ajax when clicked

Currently, I'm working on a website project where I am using a jquery/ajax script to dynamically pull in content from another page with a fade effect when clicking on a tab in the navigation menu. You can check out the effect on the page here. Only th ...

Angular2 - Actively selecting a checkbox in an ngFor loop with a reactive form

There is an object retrieved from a database that consists of a list of names with their corresponding IDs, as well as a flag to indicate whether they are selected or not. Object: let items = [{ ID: 1, Name: 'Item A', Selected: 'Y ...

Is it possible to easily extract all values associated with a particular key in a nested JSON using JavaScript?

I have a JSON structure that looks like this: [ { cells: [ { id: "1", cellType: 3, widget: { id: 1, description: "myDesc"} }, { id: "2", cellType: 4, widget: { id: 2, description: "myDesc2"} } ] }, { cells: [ { id: "3", c ...

What could be the reason for my flex items not shrinking when the browser window size is decreased?

Here is the CSS code for the header component using flexbox: .header { display: flex; flex-direction: row; justify-content: space-between; padding: 15px 20px; background-color: #ffffff; position: sticky; top: 0; z-index: ...

Is there a way to identify when a user is returning to a previous page in Angular2

How can I detect if a user has pressed the back button in their browser to navigate back while using Angular? Currently, I am subscribing to router events to achieve this. constructor(private router: Router, private activatedRoute: ActivatedRoute) { ...

CSS for two columns with a width of 50% each

Below is a table for reference: <table width="100%"> <tr> <td id="td1"></td> <td id="td2"></td> <td id="td3"></td> <td id="td4"></td> </tr> </table> Is there a wa ...

Incomplete filling of the SVG element is observed

Trying to animate SVG text to display only the outer stroke of each letter initially, followed by filling the interior with color. However, after the animation finishes, there are unfilled spaces left. Is there a property that can be applied to the SVG o ...