Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify the primeng p-calendar style?

Tags:

html

css

angular

I am trying to modify the primeng p-calendar, but it is not working properly.

For example:

I want it to be like this:required changes

But original it looks like this:original image

What i have tried so far:

HTML

<div class="nxui-form-group">
    <label for="planEndDate">
      <img src="assets/images/calendar.svg" class="nxui-icon-small nxui-icon-align-bottom">
      {{ 'i18n.all-damage-reports.label.plan-end-date' | translate }}
    </label>

    <p-calendar formControlName="planEndDate"
                class="calendar-control"
                id= "planEndDate"
                [title]="'i18n.all-damage-reports.label.plan-end-date' | translate"
                [dateFormat]="'i18n.common.dateformat.shortdate-p-calendar' | translate"
                [locale]="'i18n.common.dateformat.calendar' | translate"
    ></p-calendar>
  </div>

CSS

p-calendar.calendar-control  {
  opacity: 1;
  color: black;
  background: #eeeeee;
}

looking forward to inputs.

Thanks

like image 450
Blancho Avatar asked Feb 21 '19 09:02

Blancho


People also ask

Is there a way to pass styles in primeng?

} Alternatively, prime-ng usually allows you to pass styles in with most its components. If you look at the docs you will find that there is a style property you can use. There are also other properties you might want to play with like inputStyle. any other ideas!

How to create an angular app with primeng?

Step 1: Create an Angular application using the following command. Step 2: After creating your project folder i.e. appname, move to it using the following command. Step 3: Install PrimeNG in your given directory. Project Structure: It will look like the following. Example 2: we will use a popup style calendar.

What is the difference between P-calendar-timeonly and P-calender-wt?

p-calendar: It specifies the main container element. p-calendar-w-btn: It specifies the main container element when a button is enabled. p-calendar-timeonly: It specifies the main container element in time picker only mode.

What is the difference between P-inputtext and P-calendar-timeonly?

p-calendar: It specifies the main container element. p-calendar-w-btn: It specifies the main container element when a button is enabled. p-calendar-timeonly: It specifies the main container element in time picker only mode. p-inputtext: It specifies an input element.


2 Answers

I think that you should use the special selectors of angular to change a component style like :host or ::ng-need, you can check that in the official documentation:

https://angular.io/guide/component-styles

::ng-deep body .ui-datepicker .ui-datepicker-header .ui-datepicker-title {
margin: 0;
padding: 0;
line-height: 1;
color: goldenrod;
}

::ng-deep .ui-datepicker .ui-datepicker-group {
background-color: cadetblue;
}

Hope that'll help you !

like image 169
K.Mouna Avatar answered Oct 24 '22 14:10

K.Mouna


In my case, I want to style the calendar icon, html is below

<div class="main-container">
  <p-calendar showTime="true" hourFormat="12" [showIcon]="true"></p-calendar>
</div>

Then I added style below but it is not working:

.main-container ::ng-deep .ui-datepicker-trigger.ui-button {
  // add style here
}

Then I added p-calendar after ::ng-deep it worked

.main-container ::ng-deep p-calendar .ui-datepicker-trigger.ui-button {
  // add style here
}
like image 33
Saad Qamar Avatar answered Oct 24 '22 13:10

Saad Qamar