PrimeFlex is a CSS utility library featuring various helpers such as a grid system, flexbox, spacing, elevation and more.
PrimeFlex is not required, but it is highly recommended to add it, as such utilities are likely to be needed when developing applications with PrimeFaces. The PrimeFaces Showcase uses version 4.0.0 of PrimeFlex.
The easiest way is the WebJar: add the dependency and include the stylesheet with the h:outputStylesheet
component.
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>primeflex</artifactId>
<version>4.0.0</version>
</dependency>
<h:outputStylesheet library="webjars" name="primeflex/4.0.0/primeflex.min.css" />
Alternatively, PrimeFlex is available at GitHub. Download primeflex.min.css, add it to the resources of your
application and include its path.
<h:outputStylesheet name="%YOUR_PATH%/primeflex.min.css" />
PrimeFlex is a lightweight library, still it is possible to pick the utilities you need to make the file even smaller. For this,
remove the imports you do not need from primeflex.scss and create your own build by compiling it with SASS. For example,
if you do not use the elevation utilities, comment the import out and build your own file. Note that the sass cli has to be
available in your system, refer to the documentation for details.
@import './core/_variables';
@import './core/_mixins';
@import './core/_grid';
@import './core/_formlayout';
@import './core/_display';
@import './core/_typography';
@import './core/_flexbox';
@import './core/_spacing';
// @import './core/_elevation';
...
sass --update primeflex.scss:primeflex.min.css --style compressed
Predefined values like breakpoints can be customized when creating your own build using the core/_variables.scss file.
| Variable | Description | Default |
|---|---|---|
| $sm | Breakpoint of screens such as phones. | 576px |
| $md | Breakpoint of screens such as tablets. | 768px |
| $lg | Breakpoint of screens such as notebook monitors. | 992px |
| $xl | Breakpoint of larger screens such as desktop monitors. | 1200px |
| $gutter | Padding of a grid column. | .5rem |
| $fieldMargin | Spacing of a field. Can be vertical or horizontal depending on form layout. | 1rem |
| $fieldLabelMargin | Spacing of a field label. Can be vertical or horizontal depending on form layout. | .5rem |
| $helperTextMargin | Top spacing of a helper text. | .25rem |
| $spacer | Base value to use in spacing utilities, view spacing documentation for details. | 1rem |