Migration guide to PrimeNG v20.
PrimeNG v20 is an evolution rather than a revolution compared to v18/v19 that introduced the brand new theming architecture. V20 focuses on form enhancements along with the primeuix migration for shared theming between all Prime projects including PrimeVue, PrimeReact and the upcoming projects such as PrimeUI web components. As of v20, PrimeNG has switched PrimeNG to semantic versioning, and as a result changes are iterative, with a smooth migration strategy and no breaking changes. In the future versions, same approach will be put in action and migrations will be trivial with no breaking changes.
Our team has put in great deal of effort while updating PrimeNG, and there are no filed breaking changes in v20.
In this iteration, all form components have been reviewed and new demos for template-driven and reactive forms have been added. During this work, limitations have been identified and resolved as well. In addition, we've introduced a new property named invalid to the form components that you may use style a component as invalid. In previous versions, form components style themselves as invalid using a built-in style like the following.
.p-inputtext.ng-invalid.ng-dirty {
border-color: ${dt('inputtext.invalid.border.color')};
}
This style is opinionated as it is specifally for invalid and dirty states ignoring other potential UX requirements like touched/untouched or form submit. In v20, the new invalid provides full control to highlight a component a invalid.
<input type="text" pattern="email" [invalid]="email.invalid && (email.touched || sampleForm.submitted)" />
This styling change is backward compatible, meaning the opinionated ng-invalid.ng-dirty class is still included however in future versions, it will be removed.
PrimeUIX is a shared package between all Prime libraries, this shared approach allows PrimeTek teams to share theming and the Design team who is responsible for the Figma UI Kit to work on a single design file, which is the single source of truth. Prior to v20, PrimeNG has its own fork in default styles and for the design tokens @primeng/themes package is required. With v20, PrimeNG receives the styles from @primeuix/styles under the hood and the design tokens as theme presets are loaded from @primeuix/themes.
The components need to be adjusted to fit in the PrimeUIX theming by using the host element where applicable, as a result for the components that use host element (<p-* />) as their main container, the styleClass became obselete since native class attribute is already available on the custom element. Refer to the documentation of a particular component to find out if styleClass is deprecated.
<!-- Deprecated -->
<p-select styleClass="mx-auto" />
<!-- New -->
<p-select class="mx-auto" />
All of these changes are backward compatible, @primeng/themes use @primeuix/themes internally, and migration is easy as replacing the dependency @primeng/themes with @primeuix/themes in your application.
The following items are marked as deprecated. These are subject to soft deprecation, which means they are no longer recommended for use, but will remain available and will not be removed in future releases.
API | Deprecated Since | Replacement | Removal | Status |
---|---|---|---|---|
pTemplate | v20 | ng-template with a template reference variable | None | |
styleClass *(for host enabled components) | v20 | class | None | |
Global inputVariant | v20 | inputVariant | None | |
CamelCase Selectors | v20 | Kebab case | None | |
pButton iconPos, loadingIcon, icon and label properties | v20 | pButtonIcon and pButtonLabel directives | None | |
Button plain property | v20 | pButtonIcon and pButtonLabel directives | None | |
pButton buttonProps property | v20 | Use button properties directly on the element | None | |
p-button badgeClass property | v20 | badgeSeverity property | None | |
AutoComplete minLength property | v20 | minQueryLength | None | |
OrganizationChart preserveSpace property | v20 | Obselete property, had no use | None | |
Paginator dropdownAppendTo property | v20 | appendTo | None | |
Message text and escape properties | v20 | Content projection | None | |
Password maxLength property | v20 | maxlength property | None | |
TreeSelect containerStyle/containerStyleClass properties | v20 | style and class | None | |
Table responsiveLayout property | v20 | Always defaults to scroll, stack mode needs custom implementation | None | |
TreeSelect default template | v20 | value template | None | |
pBadge directive | v20 | OverlayBadge component | None | |
clearFilterIcon template of Table | v20 | Obsolete, not utilized. | None |
The list of items that were deprecated in previous releases and removed in this iteration.
API | Deprecated Since | Replacement | Status in v20 |
---|---|---|---|
Calendar | v18 | DatePicker | |
Dropdown | v18 | Select | |
InputSwitch | v18 | ToggleSwitch | |
OverlayPanel | v18 | Popover | |
Sidebar | v18 | Drawer | |
Chips | v18 | AutoComplete in multiple mode without typehead option | |
TabMenu | v18 | Tabs without panels | |
Steps | v18 | Stepper without panels | |
Messages | v18 | Message | |
InlineMessage | v18 | Message | |
TabView | v18 | Tabs | |
Accordion activeIndex property | v18 | value property | |
Accordion headerAriaLevel property | v18 | AccordionHeader aria-level attribute | |
AccordionTab | v18 | AccordionPanel, AccordionHeader, AccordionContent | |
AutoComplete field property | v18 | optionLabel property | |
AutoComplete itemSize property | v18 | virtualScrollItemSize property | |
pDefer | v18 | Angular deferred views | |
pAutoFocus autofocus property | v18 | Default attribute directive [pAutoFocus]="true|false" | |
Badge size property | v18 | badgeSize property | |
DatePicker monthNavigator, yearNavigator, yearRange, locale properties | v18 | Obsolete, not utilized. | |
Dialog positionLeft, responsive, breakpoint properties | v18 | Obsolete, not utilized. | |
InputMask autoFocus property | v18 | autofocus property. | |
MultiSelect checkicon template | v18 | headercheckboxicon and itemcheckboxicon. | |
MultiSelect/Select baseZIndex, autoZIndex, showTransitionOptions, hideTransitionOptions | v14 | overlayOptions property | |
Rating onCancel event and cancelIcon template | v18 | Obsolete, not utilized. | |
MultiSelect defaultLabel property | v18 | placeholder property. | |
MultiSelect/Select itemSize property | v18 | virtualScrollItemSize property | |
Select autoDisplayFirst property | v17 | Set initial value by model instead | |
TreeSelect showTransitionOptions, hideTransitionOptions | v14 | overlayOptions property | |
Panel expandIcon and collapseIcon properties | v18 | headericons template | |
StyleClass enterClass/leaveClass properties | v18 | enterFromClass and leaveFromClass properties | |
Table scrollDirection property | 14 | Obsolete, not utilized. | |
Table responsive property | 14 | An horizontal scroll is displayed for smaller screens | |
Table/TreeTable virtualRowHeight property | v18 | virtualScrollItemSize property | |
Table autoLayout property | v18 | Table always uses autoLayout as implementation requirement | |
Tree virtualNodeHeight property | v18 | virtualScrollItemSize property |