Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@Enalmada 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