import React, { useEffect, useState } from 'react'; import axios from 'axios'; import { InputText } from 'primereact/inputtext'; import { CodeHighlight } from './CodeHighlight'; const IconsDemo = () => { const [icons, setIcons] = useState([]); const [filteredIcons, setFilteredIcons] = useState([]); useEffect(() => { axios.get('assets/demo/data/icons.json').then(res => { let icons = res.data.icons; icons.sort((icon1, icon2) => { if (icon1.properties.name < icon2.properties.name) return -1; else if (icon1.properties.name < icon2.properties.name) return 1; else return 0; }); setIcons(icons); setFilteredIcons(icons); }); }, []); const onFilter = (event) => { if (!event.target.value) { setFilteredIcons(icons); } else { setFilteredIcons(icons.filter( it => { return it.icon.tags[0].includes(event.target.value); })); } } return (

Icons

PrimeReact components internally use PrimeIcons library, the official icons suite from PrimeTek.

Download

PrimeIcons is available at npm, run the following command to download it to your project.

{` npm install primeicons --save `}
Getting Started

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

{` `}
Size

Size of the icons can easily be changed using font-size property.

{` `} {` `}
Spinning Animation

Special pi-spin class applies continuous rotation to an icon.

{` `}
Constants

PrimeIcons constants API is provided to easily choose an icon with typescript e.g. when defining a menu model.

{` `} {` import {PrimeIcons} from 'primereact/api'; const items = [ { label: 'Update', icon: PrimeIcons.REFRESH, to: '/update' }, { label: 'Delete', icon: PrimeIcons.TIMES, to: '/delete' } ] `}
List of Icons

Here is the current list of PrimeIcons, more icons are added periodically. You may also request new icons at the issue tracker.

{ filteredIcons && filteredIcons.map(iconMeta => { const { icon, properties } = iconMeta; return icon.tags.indexOf('deprecate') === -1 && (
pi-{properties.name}
); }) }
) } const comparisonFn = function (prevProps, nextProps) { return prevProps.location.pathname === nextProps.location.pathname; }; export default React.memo(IconsDemo, comparisonFn);