PrimeIcons is a font icon library for PrimeTek UI libraries such as PrimeFaces.
DocumentationPrimeIcons was introduced in version 6.2.11 or higher. To use it you must include the CSS on your page
<h:outputStylesheet name="primeicons/primeicons.css" library="primefaces" />
PrimeIcons use the pi pi-{icon} syntax such as pi pi-check. A standalone icon can be displayed using an element such as i or span
<i class="pi pi-check"></i>
<i class="pi pi-times"></i>
Size of the icons can easily be changed using font-size property.
<i class="pi pi-check"></i>
<i class="pi pi-check" style="font-size: 3em"></i>
Special pi-spin class applies infinite rotate to an icon.
<i class="pi pi-spin pi-spinner" style="font-size: 3em"></i>
Here is the current list of PrimeIcons, more icons will be added periodically. You may also request new icons at the issue tracker.
<style type="text/css">
.p-grid {
text-align: center;
}
.p-grid i {
vertical-align: middle;
padding-right: 5px;
font-size: 2em;
}
.p-grid .icon-container:hover {
background-color: #EFF3F6;
cursor: pointer;
}
.dark-content .p-grid .icon-container:hover {
background-color: #5e6061;
}
.iconInfo {
background-color: #30383c;
position: fixed;
bottom: 0;
right: 0;
width: 260px;
color: #ffffff;
padding: 0 10px 5px;
display: none;
webkit-box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.3);
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.3);
border-top-left-radius: 5px;
border-top-right-radius: 5px;
z-index: 999999;
}
.iconInfo .iconInfo-header {
position: relative;
border-bottom: 1px solid #e3e9ea;
padding: 5px;
}
.iconInfo .iconInfo-close {
position: absolute;
right: 5px;
color: #ffffff;
}
.iconInfo .icon-text {
padding-top: 5px;
padding-bottom: 2px;
font-size: 13px;
}
.iconInfo .icon-sample-input {
width: 100%;
box-sizing: border-box;
margin-bottom: 5px;
}
.iconInfo .icon-sample-input + i {
text-align: center;
display: block;
font-size: 30px;
}
.iconInfo .copied-text {
display: none;
position: absolute;
right: 30px;
top: 7px;
color: #1b82d7;
font-weight: bold;
}
</style>
<script type="text/javascript">
//<![CDATA[
var grid = $('.p-grid'),
cols = grid.children('div'),
iconInfo = $('.iconInfo'),
copiedText = $('.copied-text'),
closeIcon = $('.closeInfo-close'),
colsClicked = false;
$(function() {
cols.off('click').on('click', function(e) {
showIconInfo(e);
colsClicked = true;
});
$(document.body).off('click').on('click', function(e) {
if(!colsClicked && iconInfo.is(':visible') && !iconInfo.has($(e.target)).length) {
iconInfo.hide();
}
colsClicked = false;
});
});
function onFilter(e) {
var value = $(e.target).val();
if (value == "") {
cols.show();
}
else {
cols.hide();
cols.filter('[data-name*="' + value.toLowerCase() + '"]').show();
}
}
function showIconInfo(e) {
var container = $(e.target),
iconName = "";
if(!container.hasClass('icon-container')) {
container = container.parent();
}
var iconName = container.data('name'),
iconKey = parseInt(container.data('key')).toString(16),
iconSampleInput = iconInfo.children('.icon-sample-input'),
iconSampleText = '<i class="pi pi-' + iconName + '"></i>';
iconInfo.children('.icon-text').text('pi-' + iconName + " (code: \"\\" + iconKey + "\")");
iconSampleInput.val(iconSampleText);
iconSampleInput.next().remove().end().after(iconSampleText);
if(iconInfo.is(':hidden')) {
iconInfo.show();
}
}
function copyText(e) {
$(e.target).select();
document.execCommand('copy');
copiedText.fadeIn('slow');
copiedText.fadeOut(2000);
}
function closeInfo(e) {
iconInfo.hide();
colsClicked = false;
e.preventDefault();
}
//]]>
</script>
<h3 style="margin-top:0">Getting Started</h3>
<p>PrimeIcons was introduced in version 6.2.11 or higher. To use it you must include the CSS on your page</p>
<pre name="code" class="brush:xml">
<h:outputStylesheet name="primeicons/primeicons.css" library="primefaces" />
</pre>
<h3>Usage</h3>
<p>PrimeIcons use the pi pi-{icon} syntax such as pi pi-check. A standalone icon can be displayed using an element such as i or span</p>
<pre name="code" class="brush:xml">
<i class="pi pi-check"></i>
<i class="pi pi-times"></i>
</pre>
<i class="pi pi-check"></i>
<i class="pi pi-times"></i>
<h3>Size</h3>
<p>Size of the icons can easily be changed using font-size property.</p>
<pre name="code" class="brush:xml">
<i class="pi pi-check"></i>
</pre>
<i class="pi pi-check"></i>
<pre name="code" class="brush:xml">
<i class="pi pi-check" style="font-size: 3em"></i>
</pre>
<i class="pi pi-check" style="font-size: 3em"></i>
<h3>Spinning Animation</h3>
<p>Special pi-spin class applies infinite rotate to an icon.</p>
<pre name="code" class="brush:xml">
<i class="pi pi-spin pi-spinner" style="font-size: 3em"></i>
</pre>
<i class="pi pi-spin pi-spinner" style="font-size: 3em"></i>
<h3>List of Icons</h3>
<p>Here is the current list of PrimeIcons, more icons will be added periodically. You may also <a href="https://github.com/primefaces/primeicons/issues">request new icons</a> at the issue tracker.</p>
<p:inputText onkeyup="onFilter(event)" style="width:100%; margin: 16px 0px 26px; padding: 1em;" placeholder="Search an icon" />
<div class="p-grid">
<ui:repeat value="#{primeIconsView.icons}" var="icon">
<div class="p-col-12 p-md-3 p-lg-2 icon-container" data-name="#{icon.name}" data-key="#{icon.key}">
<i class="pi pi-#{icon.name}"></i>
<div>#{icon.name}</div>
</div>
</ui:repeat>
</div>
<div class="iconInfo">
<div class="iconInfo-header">
<span>Selected Icon Info</span>
<a href="#" class="iconInfo-close" onclick="closeInfo(event)">
<i class="pi pi-times"></i>
</a>
<span class="copied-text">Copied!</span>
</div>
<div class="icon-text"></div>
<p:inputText styleClass="icon-sample-input" readonly="true" onclick="copyText(event)"/>
</div>@Named
@ApplicationScoped
public class PrimeIconsView implements Serializable {
private List<Icon> icons;
@PostConstruct
public void init() {
icons = new ArrayList<>();
String url = "https://raw.githubusercontent.com/primefaces/primeicons/2.0.0/selection.json";
try {
JSONObject json = readJsonFromUrl(url);
JSONArray iconsArray = json.getJSONArray("icons");
for(int i = 0; i < iconsArray.length(); i++) {
JSONObject properties = iconsArray.optJSONObject(i).getJSONObject("properties");
icons.add(new Icon(properties.getString("name"), properties.getInt("code")));
}
} catch (IOException | JSONException ex) {
Logger.getLogger(PrimeIconsView.class.getName()).log(Level.SEVERE, null, ex);
}
}
private static String readAll(Reader rd) throws IOException {
StringBuilder sb = new StringBuilder();
int cp;
while ((cp = rd.read()) != -1) {
sb.append((char) cp);
}
return sb.toString();
}
public JSONObject readJsonFromUrl(String url) throws IOException, JSONException {
InputStream is = new URL(url).openStream();
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = readAll(rd);
JSONObject json = new JSONObject(jsonText);
return json;
} finally {
is.close();
}
}
public List<Icon> getIcons() {
return icons;
}
public void setIcons(List<Icon> icons) {
this.icons = icons;
}
public class Icon {
private String name;
private int key;
public Icon(String name, int key) {
this.name = name;
this.key = key;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getKey() {
return key;
}
public void setKey(int key) {
this.key = key;
}
}
}