Provides search functionality on Font Awesome icons based on a icon name or category, and also provides filtering based on font style.
- The package reads meta-data related to icons from yml files
- As a user of this package, you have an option to either fetch open source files or use your own yml files (if you have purchased an icon pack)
- The package provides a search function that can be imported as a module in your project
- The module function accepts a configuration object and returns a function that can be used to search icons based on the configuration object
npm install font-awesome-search
After installation, run the bin script in cli where you want to import the package:
./node_modules/.bin/font-awesome-search -R
./node_modules/.bin/font-awesome-search --icons='icons.yml-file-absolute-path' --categories='categories.yml-file-absolute-path'
./node_modules/.bin/font-awesome-search --icons='/home/john-doe/Projects/font-awesome-search/font_awesome_yml/icons.yml' --categories='/home/john-doe/Projects/font-awesome-search/font_awesome_yml/categories.yml'
Make sure you have followed the installation steps before you start using the function.
fontAwesomeSearch(<<configuration>>)(<<search text>>)
fontStyles
is the only configuration supported as of now.
To filter the results by font style, pass fontStyles
in the configuration object.
Font styles supported:
- Regular
- Solid
- Light
- Duotone
- Brands
const search = fontAwesomeSearch({ fontStyles: ['regular', 'brands'] });
const results = search('home');
You can skip the configuration to include all styles in the result. Skipping search text will fetch all the icons.
import React, { useState } from 'react';
import fontAwesomeSearch from 'font-awesome-search';
const search = fontAwesomeSearch({
fontStyles: ['regular', 'brands', 'duotone'],
});
function App() {
const [icons, setIcons] = useState(search());
return (
<div>
<input onChange={(event) => {
setIcons(search(event.target.value))
}} />
<ul>
{icons.map((iconClass) => (
<li key={iconClass}>
<i className={iconClass}></i>
</li>
))}
</ul>
</div>
);
}
export default App;
The function has been tested on IE 10+ and is expected to work on most of the modern browsers.
Platforms the package is tested on - Windows, Linux, Mac.
The function can be integrated with most of modern JS frameworks(Angular, React, etc).
Please do contribute if you have any improvements or bug fixes.
To raise a pull request:
- Fork this repository
- Create a topic branch
- Make changes with your feature or bug fix
- Add, commit, and push your changes
- Submit a pull request