All Projects → hugoabernier → React Application Injectcss

hugoabernier / React Application Injectcss

An SPFx extension that injects CSS on every page

Programming Languages

powershell
5483 projects

Projects that are alternatives of or similar to React Application Injectcss

Generator Spfx
Open-source generator to extend the capabilities of the Microsoft SPFx generator
Stars: ✭ 150 (+650%)
Mutual labels:  sharepoint, office365
Cli Microsoft365
Manage Microsoft 365 and SharePoint Framework projects on any platform
Stars: ✭ 420 (+2000%)
Mutual labels:  sharepoint, office365
Pnp
SharePoint / Office 365 Developer Patterns and Practices - Archived older solutions. Please see https://aka.ms/m365pnp for updated guidance
Stars: ✭ 1,857 (+9185%)
Mutual labels:  sharepoint, office365
Phpspo
Office 365 Library for PHP. It allows to performs CRUD operations against Office 365 resources via an REST/OData based API
Stars: ✭ 198 (+890%)
Mutual labels:  sharepoint, office365
O365 SPO PowerShellScripts
PowerShell scripts related to SharePoint Online in Microsoft 365
Stars: ✭ 22 (+10%)
Mutual labels:  sharepoint, office365
Office365 Rest Python Client
Office 365 & Microsoft Graph Library for Python
Stars: ✭ 289 (+1345%)
Mutual labels:  sharepoint, office365
vbo365-rest-self-service
Unofficial Self-Service Web Portal for Veeam Backup for Microsoft Office 365
Stars: ✭ 24 (+20%)
Mutual labels:  sharepoint, office365
Spcb
The SharePoint Client Browser (SPCB) uses the CSOM to connect to a remote SharePoint site collection and shows the site structure with related properties and values.
Stars: ✭ 125 (+525%)
Mutual labels:  sharepoint, office365
Pnp Sites Core
Microsoft 365 Dev PnP Core component (.NET) targeted for increasing developer productivity with CSOM based solutions.
Stars: ✭ 411 (+1955%)
Mutual labels:  sharepoint, office365
vbo365-rest
Unofficial Self-Service Web Portal for Veeam Backup for Microsoft Office 365
Stars: ✭ 44 (+120%)
Mutual labels:  sharepoint, office365
pnp-starterkit-setup
x-platform setup script for the SharePoint Starter Kit
Stars: ✭ 14 (-30%)
Mutual labels:  sharepoint, office365
gulp-spsync
Gulp plugin for synchronizing local files with a SharePoint library
Stars: ✭ 57 (+185%)
Mutual labels:  sharepoint, office365
powershell
PnP PowerShell
Stars: ✭ 326 (+1530%)
Mutual labels:  sharepoint, office365
Microsoft365dsc
Manages, configures, extracts and monitors Microsoft 365 tenant configurations
Stars: ✭ 374 (+1770%)
Mutual labels:  sharepoint, office365
Spfx 40 Fantastics
This package is a sample kit of Client Side Web Parts built on the SharePoint Framework SPFx. You can find here different kind of high visual web parts as carousel, images galleries, animations, map, editors, etc.
Stars: ✭ 345 (+1625%)
Mutual labels:  sharepoint
Python O365
A simple python library to interact with Microsoft Graph and Office 365 API
Stars: ✭ 742 (+3610%)
Mutual labels:  sharepoint
Hawk
Powershell Based tool for gathering information related to O365 intrusions and potential Breaches
Stars: ✭ 304 (+1420%)
Mutual labels:  office365
Baristacore
BaristaCore is a framework for providing a serverless platform using ChakraCore and .Net Core
Stars: ✭ 24 (+20%)
Mutual labels:  sharepoint
Microsoft Graph Toolkit
Authentication Providers and UI components for Microsoft Graph 🦒
Stars: ✭ 518 (+2490%)
Mutual labels:  sharepoint
Magento2 Gmail Smtp App
Configure Magento 2 to send email using Google App, Gmail, Amazon Simple Email Service (SES), Microsoft Office365 and many other SMTP (Simple Mail Transfer Protocol) servers
Stars: ✭ 281 (+1305%)
Mutual labels:  office365

SPFx Applications Customiser CSS Injection

Summary

This sample shows how to inject a custom Cascading Style Sheet (CSS) on modern pages.

Sample super ugly CSS to illustrate custom CSS injection

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.

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.

In this example, we deploy the CSS in a shared location; this allows us to change the CSS file at any time without re-deploying or re-configuring the application customizer.

You can deploy the application customizer with different settings to point to different CSS files.

Please refrain from making drastic changes that may negatively impact your users' experience. If you experience issues with modern pages, please try disabling the extension before calling Microsoft Support to ensure that the issue isn't caused by your custom CSS.

Used SharePoint Framework Version

SPFx v1.8

Applies to

Solution

Solution Author(s)
react-application-injectcss Hugo Bernier (Tahoe Ninjas, @bernierh)

Version history

Version Date Comments
1.0.0 07 May, 2018 Initial release
1.1.0 18 October, 2018 Updated to SPFx 1.6
1.2.0 28 March, 2018 Updated to SPFx 1.8

Disclaimer

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.


Minimal Path to Awesome

Prepare the assets

  1. create a custom CSS file that meets your needs. For example, this CSS will change the feedback button's background color to orange.
.sitePage-uservoice-button {
  background-color: orange;
 }
  1. Upload the CSS file as custom.css to your Styles Library of the root site collection (i.e.: https://<yourtenant>.sharepoint.com/Style%20Library/Forms/AllItems.aspx).
  2. Navigate to your site. Your custom CSS should be applied.

For example, the CSS provided above will make the feedback button appear as follows: Orange Feedback

Build the solution

  1. clone repo
  2. Ryn npm install
  3. Run gulp bundle --ship
  4. Run gulp package-solution --ship

Manual deployment

  1. Upload the react-application-injectcss.sppkg from the sharepoint folder to your App catalog.
  2. When prompted to deploy to all sites, choose the option that suits your needs.

Automated deployment

  1. If you have not done so already, install the PnP PowerShell Cmdlets
  2. Edit the DeployApplicationCustomizer.ps1 file and change the $tenantUrl variable to point to your tenant.
  3. From a PowerShell console, run the DeployApplicationCustomizer.ps1 script to automatically deploy to all sites.
  4. You will be prompted to enter your credentials.
  5. After providing your credentials, the extension will be deployed

Changing the CSS location

To simplify deployment, the extension looks for a custom.css in your tenant's root Style Library. If you wish to use a different CSS name and location, use one of the following approaches:

In the solution

This approach will change the default css location in the solution so that it will automatically load your custom CSS when the extension is deployed.

Note that if you intend to deploy this extension tenant-wide, your custom CSS URL should be an absolute URL or a server-relative URL.

  1. Locate the elements.xml file, in the sharepoint > assets folder
  2. Change the ClientSideComponentProperties to point to your custom CSS URL.
  3. Run gulp bundle --ship
  4. Run gulp package-solution --ship
  5. Upload the react-application-injectcss.sppkg from the sharepoint folder to your App catalog.
  6. When prompted to deploy to all sites, choose the option that suits your needs.

Using automated deployment

This approach allows you to override the CSS location by configuring the extension properties as the extension is activated.

  1. Edit the EnableApplicationCustomizer.ps1 file and change the $tenantUrl variable to point to your tenant.
  2. In the same file, change the $customCSSUrl variable to point to your custom CSS URL.
  3. From a PowerShell console, run the EnableApplicationCustomizer.ps1 script to automatically deploy to all sites.
  4. You will be prompted to enter your credentials.
  5. After providing your credentials, the extension will be deployed using your custom CSS URL.

Disabling the extension

  1. Edit the DisableApplicationCustomizer.ps1 file and change the $tenantUrl variable to point to your tenant.
  2. From a PowerShell console, run the DisableApplicationCustomizer.ps1 script to automatically deploy to all sites.
  3. You will be prompted to enter your credentials.
  4. If prompted to remove the application, choose Yes.
  5. The extension will be removed.

If you wish to do so, you can remove the solution package from your tenant's app catalog after the extension has been de-activated.

Features

Sample SharePoint Framework Application Customiser which injects a custom CSS in the HTML header.

This sample illustrates the following concepts on top of the SharePoint Framework:

  • HTML manipulation
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].