11

i am using primeNG for angular

https://www.primefaces.org/primeng/#/flexgrid

when i am trying this

<div class="p-grid">
<div class="p-col-6">
<div class="box">6 </div>
</div>
<div class="p-col-6">
<div class="box">6 </div>
</div>

</div>

the boxs are on top of each other and not next to each other i run

npm install primeflex --save

and added

"node_modules/primeflex/primeflex.css"

to angular.json

seems to be some thing related to the primeflex.css

the p-col class is working fine but the p-col-# (p-col-1 , p-col-2 etc ) are not working as excpected

this is the values for the p-col

-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
-ms-flex-preferred-size: 0;
flex-basis: 0;
padding: 0.5em;

this is the values for the p-col-#

-webkit-box-flex: 0;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
padding: 0.5em;

if for exmample i change the padding of the p-col-# to 0 then it is working but i don't have padding.. (i tried to change the p-col-# to the same values as the p-col and it is not working )

any ideas ?

Thanks Rahav

RMagen
  • 612
  • 2
  • 9
  • 23
  • 1
    First time I implemented primeflex followed the steps given by you. It is working perfectly. Whenever you make any changes in angular.json you should restart the app to apply the changes. I used angular v6, primeng v6 and cli v6 and node vs 8. For reference check my git here [git](https://github.com/alokkarma/angular6-primeNg/blob/development/src/app/about/about.component.html) – DirtyMind Sep 13 '18 at 18:50
  • for me it is not working , i run npm update --save to update to lastest version Angular CLI: 6.2.2 , Node: 8.9.3 ,Angular: 6.1.7 , "primeng": "^6.1.3", "primeflex": "^1.0.0-rc.1", but it is still not working – RMagen Sep 16 '18 at 06:05
  • i had same issue with primeflex version 3, it worked on changing same with version 2 – Sandip Ghadge Aug 20 '21 at 05:50

6 Answers6

18

It is work in my Angular6 project.

  1. install PrimeNG and PrimeFlex

    npm install primeng --save
    npm install primeflex --save
    
  2. add style to angular.json

    "./node_modules/primeng/resources/primeng.css",
    "./node_modules/primeflex/primeflex.css"
    

app.component.html

<div class="p-grid">
    <div class="p-col">1</div>
    <div class="p-col">2</div>
    <div class="p-col">3</div>
</div>
Sato
  • 181
  • 3
13

use "grid" instead of "p-grid", there is class name change in lib files.

Roshan Singh
  • 131
  • 1
  • 4
  • 1
    I can confirm, it looks like removing the "p-" prefix is the solution with the following versions "primeflex": "^3.0.1", "primeicons": "^4.1.0", "primeng": "^12.1.0-rc.1", – Sim_on Aug 20 '21 at 14:33
  • This worked for me as well, though I had to also change the nested "p-col" classes to "col". – tengen Sep 13 '21 at 18:41
  • yes they toke all p-* https://github.com/primefaces/primeflex/compare/2.0.0-rc.1...master . for me i was using old version of primeng which cause incompatibility issue – Abdullah Tahan Nov 04 '21 at 08:32
3

I had the same problem in Angular 7 with PrimeNG PrimeFlex.

Added the following to the styles.css file to fix it.

 * {
  -webkit-box-sizing: border-box;
}
ALB
  • 31
  • 1
2

For PrimeNG version 3 or more use "grid" instead of "p-grid" and "col" instead of "p-col".

No need to update any library.

Note - Stack - Angular 12 and PrimeNG 3.X.X

Nitin Rathod
  • 129
  • 1
  • 1
  • 6
1
  1. install PrimeNG and PrimeFlex

    npm install primeng --save
    
    npm i primeflex@2.0.0 --save
    
  2. add style to angular.json

    "./node_modules/primeng/resources/primeng.css",
    
    "./node_modules/primeflex/primeflex.css"
    

Please use primeflex 2.0.0 , Latest version (3+) have some issues.

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
0

In addition to the other answers about removing the p- from grid and col in PrimeNG PrimeFlex version 3, I had to go through the source code to find that the breakpoints have also changed to a new syntax.

Old: p-sm-6 New: sm:col-8

Example:

<div class="grid">
  <div class="col-12 sm:col-10 md:col-8 lg:col-6 xl:col-4">
    <!-- Column content -->
  <div>
</div>
RcoderNY
  • 1,204
  • 2
  • 16
  • 23