DatoCMS plugin to visually select icons from any icon font.
A field that holds general options in JSON format.
my-prefix icon-arrow-right
), you an add it here (optional)The plugin needs to know the icon names (that is, the CSS class names). They can be added as a JSON array in this field.
Example:
These names will be returned when selecting an icon, see the "Usage" section below for more.
If you would like to add filter checkboxes to the UI, you can set "filters" here.
Filters consist of two parts:
Example:
1[2 {3 "name": "Arrow icons",4 "value": "arrow"5 },6 {7 "name": "Filled icons",8 "value": "-fill"9 }10]
The plugin was made to be self-contained and to be used with any icon fonts. Because of this, all font-related CSS should be put here:
.icon-arrow-right:before { content: '\ea8a'; }
After installing the plugin, you'll need to add a new JSON field type to a block or model, go to the Presentation tab, and select "Icon Font Picker" for the Field editor.
The data structure will be a stringified JSON object with the following structure:
1{2 "icon": "icon-arrow-right"3}
You can use it on the frontend by adding as a class to an element, like the way icon fonts are used normally.
If run locally, the plugin is available at port 3022: http://localhost:3022
.
This served as the base of this plugin and helped a lot to bring things together easily.
<https://www.datocms.com/marketplace/plugins/i/datocms-plugin-fontawesome>
The JsonTextArea used for the plugins was borrowed from here. Great plugin by the way.
<https://www.datocms.com/marketplace/plugins/i/datocms-plugin-visual-select>