|
1 | | -# react-application-injectcss |
2 | | -An SPFx extension that injects CSS on every page |
| 1 | +# Spfx Applications Customiser CSS Injection |
| 2 | + |
| 3 | +## Summary |
| 4 | +This sample shows how to inject a custom Cascading Style Sheet (CSS) on modern pages. |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +__Note__: This code is provided as a sample only. Keep in mind that Microsoft may change page elements and styles at any time, rendering your custom CSS useless. It is preferrable to use well-known HTML element placeholders. |
| 9 | + |
| 10 | +When you need to make minor cosmetic changes to modern pages (e.g.: match your corporate branding guidelines) and cannot use placeholders,you can create a custom CSS and inject on every modern page. |
| 11 | + |
| 12 | + |
| 13 | +## Used SharePoint Framework Version |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +## Applies to |
| 18 | + |
| 19 | +* [SharePoint Framework Extensions](https://dev.office.com/sharepoint/docs/spfx/extensions/overview-extensions) |
| 20 | +* [Office 365 developer tenant](http://dev.office.com/sharepoint/docs/spfx/set-up-your-developer-tenant) |
| 21 | + |
| 22 | +## Solution |
| 23 | + |
| 24 | +Solution|Author(s) |
| 25 | +--------|--------- |
| 26 | +react-application-injectcss|Hugo Bernier ([Tahoe Ninjas](http://tahoeninjas.blog), @bernierh) |
| 27 | + |
| 28 | +## Version history |
| 29 | + |
| 30 | +Version|Date|Comments |
| 31 | +-------|----|-------- |
| 32 | +1.0.0|07 May, 2018|Initial release |
| 33 | + |
| 34 | +## Disclaimer |
| 35 | + |
| 36 | +**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.** |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +## Minimal Path to Awesome |
| 41 | + |
| 42 | +* clone repo |
| 43 | +* create a custom CSS file that meets your needs. For example, this CSS will make the site logos round and will add an ugly red colour at the top of every page. |
| 44 | + |
| 45 | +``` |
| 46 | +.ms-compositeHeader { |
| 47 | + background-color: red; |
| 48 | +} |
| 49 | +
|
| 50 | +.ms-siteLogoContainerOuter { |
| 51 | + border-radius: 50%; |
| 52 | + border-width: 3px; |
| 53 | +} |
| 54 | +
|
| 55 | +.ms-siteLogo-actual { |
| 56 | + border-radius: 50%; |
| 57 | +} |
| 58 | +``` |
| 59 | +* upload the CSS file to a shared location on your SharePoint tenant. For example, in the `Styles Library` of the root site collection. |
| 60 | +* get the URL to your custom CSS. For example: `/Style%20Library/custom.css` |
| 61 | + |
| 62 | +* update _serve.json_ pointing to your site collection home page change the `cssurl` property with the URL to your custom CSS. |
| 63 | +* run _gulp serve_ |
| 64 | + |
| 65 | +## Features |
| 66 | + |
| 67 | +Sample SharePoint Framework application customiser injecting a custom CSS in the HTML header. |
| 68 | + |
| 69 | +This sample illustrates the following concepts on top of the SharePoint Framework: |
| 70 | + |
| 71 | +* HTML manipulation |
0 commit comments