Date/Time Input
Overview
Use the date/time input component to prompt the user to enter both a date value and a time value, together.

Development
Web component development
Component reference
p-calendar
Allows user to edit date/time values in a non-mobile environment
View the p-calendar reference doc
If you're adding PrimeNG to your solution for the first time, reference their setup documentation. It's important to note that the inclusion of the nova-light theme css is not necessary to work with Responsive UI. Styling for the PrimeNG components is provided by Responsive UI's theming.
Implementation
There are two different experiences for inputting date values: one for desktop and another for tablet and mobile. It’s a good practice to support both approaches for your date and date/time fields if your app will run in both environments.
Prompting for Date/Time on Desktop
Start by importing the CalendarModule and BrowserAnimationsModule modules.
For desktop devices, use the p-calendar calender component from PrimeNG. Add the rui-hidden-mobile-device CSS class to the input to only display it on desktop.
If you need to prompt for time in addition to date, add the showTime and hourFormat properties to the p-calendar as noted in the PrimeNG documentation.
The example below shows a p-calendar for desktop and an input for tablet and mobile. Nest all of these elements within a div that has both the input-group and rui-datepicker CSS classes.
If you place a date picker within a tabbed interface, you may experience clipping of the calendar depending your form layout and tab size.
In order to allow the date picker element to render outside of the tab content area, use the appendTo attribute on your p-calendar and assign the value to “body”:<p-calendar appendTo="body" ...></p-calendar>
Or bind it to another parent ng-template variable:<div #calendarContainer><p-calendar [appendTo]="calendarContainer" ...></p-calendar></div>
Prompting for Date/Time on Tablet and Mobile
For mobile devices, simply use input type="date". The browser will display the native date picker experience for those devices, which is much better suited to those environments than the desktop date picker popup. Add the rui-visible-mobile-device CSS class to the input to only display it on tablet and mobile.
If you need to prompt for time in addition to date, set the input type to datetime-local.
The example below shows a p-calendar for desktop and an input for tablet and mobile. Nest all of these elements within a div that has both the input-group and rui-datepicker CSS classes.
Prompting for Date/Time with a Smaller Footprint
If you want a date input with a smaller visual footprint, consider using a standard button to toggle the date picker. This would render a single button that displays the date value. Add a date picker input, but hide it using the invisible class. When you press the button, it displays the same date picker popup. The upside to using this approach is that it takes up less width than the input and the standard datepicker button, making it ideal for cases where space is at a premium, including toolbars. The downside is that in some cases it can take longer for the user to select the year, month, and day using a mouse than by just typing it into a standard date input. Two-way bind the ngModel attribute of your input to a date value in your controller as you would with a standard date picker.
Angular component development
Component reference
p-calendar
Allows user to edit date/time values in a non-mobile environment
View the p-calendar reference doc
If you're adding PrimeNG to your solution for the first time, reference their setup documentation. It's important to note that the inclusion of the nova-light theme css is not necessary to work with Responsive UI. Styling for the PrimeNG components is provided by Responsive UI's theming.
Implementation
There are two different experiences for inputting date values: one for desktop and another for tablet and mobile. It’s a good practice to support both approaches for your date and date/time fields if your app will run in both environments.
Prompting for Date/Time on Desktop
Start by importing the CalendarModule and BrowserAnimationsModule modules.
For desktop devices, use the p-calendar calender component from PrimeNG. Add the jha-hidden-mobile-device CSS class to the input to only display it on desktop.
If you need to prompt for time in addition to date, add the showTime and hourFormat properties to the p-calendar as noted in the PrimeNG documentation.
The example below shows a p-calendar for desktop and an input for tablet and mobile. Nest all of these elements within a div that has both the input-group and jha-datepicker CSS classes.
If you place a date picker within a tabbed interface, you may experience clipping of the calendar depending your form layout and tab size.
In order to allow the date picker element to render outside of the tab content area, use the appendTo attribute on your p-calendar and assign the value to “body”:<p-calendar appendTo="body" ...></p-calendar>
Or bind it to another parent ng-template variable:<div #calendarContainer><p-calendar [appendTo]="calendarContainer" ...></p-calendar></div>
Prompting for Date/Time on Tablet and Mobile
For mobile devices, simply use input type="date". The browser will display the native date picker experience for those devices, which is much better suited to those environments than the desktop date picker popup. Add the jha-visible-mobile-device CSS class to the input to only display it on tablet and mobile.
If you need to prompt for time in addition to date, set the input type to datetime-local.
The example below shows a p-calendar for desktop and an input for tablet and mobile. Nest all of these elements within a div that has both the input-group and jha-datepicker CSS classes.
Prompting for Date/Time with a Smaller Footprint
If you want a date input with a smaller visual footprint, consider using a standard button to toggle the date picker. This would render a single button that displays the date value. Add a date picker input, but hide it using the invisible class. When you press the button, it displays the same date picker popup. The upside to using this approach is that it takes up less width than the input and the standard datepicker button, making it ideal for cases where space is at a premium, including toolbars. The downside is that in some cases it can take longer for the user to select the year, month, and day using a mouse than by just typing it into a standard date input. Two-way bind the ngModel attribute of your input to a date value in your controller as you would with a standard date picker.
Design
Figma design
| Dev Component | Design Component Name |
|---|---|
| Date input | RUI / Forms / Date Input |
| Inline date input | RUI / Forms / Inline Date Input |
| Inline time input | RUI / Forms / Inline Time Input |
| Inline date/time input | RUI / Forms / Inline Date Time Input |
Adobe XD design
- Sample App - Editing Form Data
| Dev Component | Design Component Name |
|---|---|
| Date input | JHA / Forms / Date Input |
| Inline date input | JHA / Forms / Inline Date Input |
| Inline time input | JHA / Forms / Inline Time Input |
| Inline date/time input | JHA / Forms / Inline Date/Time Input |