Office UI Fabric JS
Microsoft no longer supports this content and will not be responding to bugs or issues. We recommend using the newer version Office UI Fabric React as your front-end framework.

Get started with Fabric JS

Use the CDN, Bower, NPM, or Nuget to get the components and core styling.

  1. The easiest way to get Fabric is by referencing the CDN. Include the following in the <head> of your page:

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

    To reference the latest version, just change the version number in the URL to your desired version. All versions of Fabric are on the CDN, and the latest version is 1.4.0.

  2. Copy the HTML from one of the samples into your page. For example with the button

    			<button class="ms-Button">
      <span class="ms-Button-label">Create Account</span>
    </button>
    		
  3. Add the appropriate <script> tag to your page below the references to Fabric's JavaScript to instantiate, for example, all the Button components on the page:

    			<script type="text/javascript">
    var ButtonElements = document.querySelectorAll(".ms-Button.AlertExamples");
    for(var i = 0; i < ButtonElements.length; i++) {
      new fabric["Button"](ButtonElements[i], function() {
        alert("You clicked a New User button");
      });
    }
    </script>
    		

    Or, for example add the appropriate <script> tag to your page to instantiate a single Button component on the page

    			<script type="text/javascript">
    var ButtonComponent = document.querySelector(".ms-Button.AlertExample");
    new fabric["Button"](ButtonComponent, function() {
      alert("You clicked the Create Account button");
    });
    </script>
    		
  4. You can also reference styles from Fabric Core, such as the type styles:

    			<span class="ms-font-su ms-fontColor-themePrimary">Big blue text</span>
    		

    For more information on assets and styles available in Fabric Core, check out the Styles documentation.

Other ways to get Fabric JS

To build Fabric JS locally, you can follow the steps outlined in the building documentation. To get Fabric via a package manager such as NuGet, npm, or Bower, you can follow the package manager documentation.

Need a component Fabric JS doesn’t have?

Check the Fabric JS Trello board and vote up the request so we can track it. If you don’t see an existing card, please file an issue in the repository and we’ll add the card for you.