Skip to content
SPFX integration for theme support - SharePoint Framework
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets Updated CSS Documentation Aug 29, 2018
docs Updated Readme Aug 29, 2018
tests PR #10: Add ms-accent variable Dec 20, 2018
.gitignore
.travis.yml Updated tavis.yml Nov 26, 2017
LICENSE Initial commit Sep 2, 2017
README.md Updated Readme Aug 29, 2018
_office.theme.functions.scss Added Unit Testing for Sass functions Nov 21, 2017
_office.theme.scss Font weight functionality added Nov 22, 2017
_office.theme.settings.scss Implementation REM and REM Test for font sizes Nov 26, 2017
_office.theme.typography.scss
_office.theme.vars.scss PR #10: Add ms-accent variable Dec 20, 2018
gulpfile.js Updated gulpfile.js developed first css type test Nov 24, 2017
index.js PR #10: Add ms-accent variable Dec 20, 2018
package.json chore(package): update mocha to version 6.0.0 Feb 18, 2019
test.js Updated gulpfile.js developed first css type test Nov 24, 2017
yarn.lock chore(package): update lockfile yarn.lock Feb 18, 2019

README.md

Build Status Greenkeeper badge

Office UI Fabric and Office 365 Theme support for SharePoint Framework Projects

This NPM package allows you to use theme token from Office UI Frabric in SharPoint Framework Projects.

Installation

Create a new SharePoint Framework Project and add this package to your project.

npm install --save-dev spfx-uifabric-themes 

After this installation this package should be listed as a dev dependency in your SPFX Project.

Usage

Go to any of your .module.scss files in your project and include the following SASS @import statement

// For all tools and utlities
@import './node_modules/spfx-uifabric-themes/office.theme';

If only the color variables are needed in the SPFX Project only the variables can be included too.

// For color variables only
@import './node_modules/spfx-uifabric-themes/office.theme.vars';

After that you can use theme slots like $ms-themePrimary.

@import './node_modules/spfx-uifabric-themes/office.theme';

.container {
  background-color: $ms-themePrimary;
}
// For Error Messages use you can pass: alert, error, info, servere, success
.custErrorMsg{
  padding: 0 1em;
  line-height: 2em;
  @include stateStyle('error');
}

This will automatically add the theme slot for the background color.

.container_742604fa {
  background-color: "[theme:themePrimary, default:#0078d7]"
}

.custErrorMsg_742604fa {
  padding: 0 1em;
  line-height: 2em;
  background-color: "[theme:errorBackground, default: #fde7e9]";
  color: "[theme:errorText, default: #333333]"
}

CSS Variable support for SPFx projects

Now native CSS variable can also be used in SPFx project using this project. Read everything on this in my blog post or on the dedicated documentation page

Additional functions

You will find all additional functions in the documentation:

  • Typopgraphy
    Create font-weight, font-styles and general text styles
  • State styles
    Creates alert, error, info, server and success styles

License

MIT License

Copyright (c) 2017 Stefan Bauer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You can’t perform that action at this time.