Every icon attribute takes plain style classes, so any icon font can be used.
PrimeIcons, the
icon font of PrimeTek, is part
of the PrimeFaces JAR and available on every page, nothing has to be installed.
FontAwesome can be added with a single dependency.
PrimeIcons use the pi pi-{icon} syntax such as pi pi-check.
A standalone icon can be displayed using an element like i or span.
<i class="pi pi-check"></i>
<i class="pi pi-times"></i>
Components with an icon take the same style classes in their icon attribute.
<p:commandButton value="Save" icon="pi pi-check"/>
Size of the icons can easily be changed using the font-size property.
<i class="pi pi-check"></i>
<i class="pi pi-check" style="font-size: 2rem"></i>
The pi-spin class applies a continuous rotation to an icon.
<i class="pi pi-spin pi-spinner" style="font-size: 2rem"></i>
PrimeFaces supports FontAwesome 4.x,
5.x and 6.x+. It is not bundled, add the WebJar to your pom.xml:
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>6.7.2</version>
</dependency>
Then include the stylesheet. The -jsf variant resolves the font URLs through the Faces resource handler.
<h:outputStylesheet library="webjars" name="font-awesome/6.7.2/css/all.min-jsf.css"/>
Icons are used just like PrimeIcons, in markup or in the icon attribute of a component.
Add v4-shims.min-jsf.css as well to keep using the old fa fa-{icon} syntax of 4.x.
<i class="fa-solid fa-house"></i>
<p:commandButton value="Save" icon="fa-solid fa-floppy-disk"/>
Here is the current list of PrimeIcons, more icons are added periodically. You may also request new icons at the issue tracker.