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 (
PrimeReact components internally use PrimeIcons library, the official icons suite from PrimeTek.
PrimeIcons is available at npm, run the following command to download it to your project.
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 of the icons can easily be changed using font-size property.
Special pi-spin class applies continuous rotation to an icon.
PrimeIcons constants API is provided to easily choose an icon with typescript e.g. when defining a menu model.
Here is the current list of PrimeIcons, more icons are added periodically. You may also request new icons at the issue tracker.