Skip to content

Instantly share code, notes, and snippets.

@Enalmada
Created October 4, 2018 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Enalmada/ef000077a5f7c73d7900da005b1ad6e8 to your computer and use it in GitHub Desktop.
Save Enalmada/ef000077a5f7c73d7900da005b1ad6e8 to your computer and use it in GitHub Desktop.
reason-react bindings for Font Awesome 5
[@bs.module "@fortawesome/react-fontawesome"] external reactClass : ReasonReact.reactClass = "FontAwesomeIcon";
[@bs.obj]
external makeProps:
(
~icon: array(string),
~id: string=?,
~className: string=?,
~style: ReactDOMRe.Style.t=?,
unit
) =>
_ =
"";
let make = (~icon, ~id=?, ~className=?, ~style=?, children) =>
ReasonReact.wrapJsForReason(
~reactClass,
~props=
makeProps(
~icon=Array.of_list(icon),
~id?,
~className?,
~style?,
(),
),
children,
);
@Enalmada
Copy link
Author

Enalmada commented Oct 4, 2018

Disclaimer: I am very new at bindings and just did something up quick to keep me going. Eventually this could be published as bs-font-awesome or something but it is so small right now it is best to copy it in to your reasonml bindings directory.

I am currently using it in a Next.js project with app wrapper initializing font awesome with regular javascript (ex: https://github.com/Alrefai/next-calorie )and then using the icons in reason files:

<FontAwesomeIcon icon=["fal", "comments"] className="fa-5x" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment