Wednesday, January 3, 2018

How to get the magic SharePoint site colors

image

You see them everywhere in SharePoint, these purple, pink, blue and green random colors. I have previously written about these colors, but this time around I’ll offer code so you can generate those colors yourself if you for example are building search based solutions to list out sites.

The below code is assembled based on code I found in the Office UI Fabric for the Persona component and you can use it like this:

import { ColorHelper } from './ColorHelper';
.
.
let bgColorHex = ColorHelper.HexCodeFromText("Some Text");
Github Gist Code

No comments:

Post a Comment