2

I would like to know if I should install nodeJs to use Office UI Fabric JS compenents ?

3

No its not needed to install Node js.

You can simply reference the Office fabric components from CDN or download it locally and then upload in your SP environment like site assets or style library.

You can add the below references in the <head> section of master page or inside script editor or page layout etc.

<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/css/fabric.min.css">
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/css/fabric.components.min.css">
<script src="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/js/fabric.min.js"></script>

Reference - Office UI Fabric js

Office fabric components list

For example, if you want to use Fabric UI button, you can use the below html:

<button class="ms-Button">
  <span class="ms-Button-label">Create Account</span>
</button>

After that, you can instantiate it as below:

<script type="text/javascript">
    var ButtonElements = document.querySelectorAll(".ms-Button");
    for(var i = 0; i < ButtonElements.length; i++) {
        new fabric['Button'](ButtonElements[i], function() {
            // Insert Event Here
        });
    }
</script>

Reference - Fabric UI Button

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.