0.2.1 • Published 9 months ago

strapi-react-icons v0.2.1

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Strapi Plugin React Icons

A plugin for Strapi v4 that gives users a custom field and search bar for the library react-icons.

Installation

Step 1: Install with package manager of your choice.

Install strapi-react-icons with yarn or npm:

  • Install with yarn:
  yarn add strapi-react-icons
  • Install with npm:
  npm i strapi-react-icons

Step 2: Rebuild your Strapi Admin Panel:

  • Rebuild with yarn:
  yarn build
  • Rebuild with npm:
  npm run build

Screenshot Guide

Step 1:

Navigate to the strapi-react-icons settings page (Shown in the screenshot below):

1

Step 2:

Click the button that says "Import default icon libraries" to import the icons:

  • The functionality to disable/enable select libraries is not implemented yet, so leave the checkboxes as-is.
  • You will be able to filter the libraries, somewhat, when interacting with the field.

2

Step 3:

In your Content-Type Builder, press the Add new field button. Navigate to the tab that says CUSTOM and click on the field labelled, react-icon.

Press Save to save to restart your Strapi server.

3

Step 4:

Navigate to your select Content Type that you just created and click on the search icon to bring up an icon search modal.

4

By default, all icon libraries are (lazily) loaded.

5

Step 5:

In order to find the icons you want, you can either search for the keyword using the search bar, or you can filter the icons shown using the select menu in the bottem left hand side of the modal.

No Filtering, searching for a briefcase icon.

6

Filtering to only show Font Awesome 5 Icons (fa5), searching for a briefcase icon.

7

Step 6:

Click on the icon that best suits your needs, it should populate the custom field.

Finally, press Save to save your changes and Publish to publish them. Enjoy!

8

Usage/Examples

In Strapi v4

  • Select your prefered icon libraries on the settings page.
  • Add react-icon as custom field to your content type.
  • Press the search icon to select a icon from any of the selected icon libraries.

In React / Next.js

Create the following IconComponent to dynamically show the icon:

import * as ReactIcons from "react-icons/all";

interface IIconComponent {
  icon: string;
  size?: number;
}

type IReactIcon = keyof typeof ReactIcons;

const IconComponent: React.FC<IIconComponent> = ({ icon, size }) => {
  const DynamicIconComponent = ReactIcons[icon as IReactIcon];

  if (undefined === DynamicIconComponent) return <></>;

  return <DynamicIconComponent size={size} />;
};

Roadmap

  • Add a default All Libraries option to the modal.

  • Fix varying bugs.

Authors

Contributers

0.2.0-alpha.2

11 months ago

0.2.0-alpha.1

11 months ago

0.2.0-alpha.4

11 months ago

0.2.0-alpha.3

11 months ago

0.2.1

9 months ago

0.1.2

11 months ago

0.2.0

11 months ago

0.1.1

12 months ago

0.1.3

11 months ago

0.1.0

12 months ago

0.0.17

12 months ago

0.0.16

12 months ago

0.0.15

12 months ago

0.0.14

12 months ago

0.0.13

12 months ago

0.0.12

12 months ago

0.0.11

12 months ago

0.0.10

12 months ago

0.0.9

12 months ago

0.0.8

12 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.5

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago