SharePoint Online Column Formatting Options

I wanted an exhaustive list (to be updated in future with updates) of Column Formatting options from this GitHub repo. 

It allows to format a SharePoint Online or SharePoint 2019 list or document library using some JSON code.

For SharePoint 2019, there are limitation and few things to know.

Chris Kent has released a great tool as SPFX webpart helping designing your column formatting, make sure you check it out.

Click on each header, to access the detailed page about how to achieve each formatting.

Last article update : 13.05.2020

Formatting an item when a date column is before or after today’s date


Add an action button to a field


Turn field values into hyperlinks


 

Project Indicator Formats

screenshot41

Project Register where ‘Current Status’ column is formatted based on the RYAG status. 

screenshot8

Conditional formatting based on a number range


Format a number column as a data bar

screenshot of the Simple Data Bar

screenshot of the Percentage Data Bar

Show trending up/trending down icons


Conditional formatting based on the value in a text or choice field


Traffic Light (Red-Yellow-Green) Status Indicator


Formatting Yes/No field to check mark based on the value in the field


Yes/No Column Check Mark


Concatenate Currency Symbol to Numeric Columns (added 07/02/2018)

budgetcolumnformating.png

 

Displays a customizable Google map image for a given location

 

screenshot7

 

Display Twitter profile pics using Twitter handles

screenshot6

Formatting percentage number (%) to pie chart.

number-piechart

Highlight the current user

screenshot of the sample

Display a picture column as a circle

screenshot4

Display a person’s profile picture in a circle

screenshot3

Create a button to launch a Flow for the selected item

screenshot of the sample

SVG icons

screenshot1

Smiley faces for good quiz results

screenshot of the sample

Formatting an ISBN (text column) to book cover image. Images are retrieved by calling Open Library Covers API.

Summary

This example retrieves book cover images based on their ISBN numbers by utilizing the Open Library Covers API. The API works by building a cover image URL with the ISBN.

text-isbn-image

Formatting column with long text to multiple-line with word wrap.

screenshot of the sample

Strikethrough on Completion

screenshot of the sample

Display Twitter profile pics using Twitter handles

 

screenshot of the sample

Display social media profile pics using social media handles

screenshot of the sample

Turn FileRef field into clickable thumbnail hyperlink

screenshot of the sample

Centered Content

screenshot of the sample

Creating Red-Amber-Green (RAG) bars based on date ranges

screenshot of the sample

Concatenate Currency Symbol to Numeric Columns

screenshot of sample

Demonstrates how to link to a local resource

 

screenshot of the sample

Note – this format only provides the link shown above in the “List” column. The image is related to the text-local-imagesample. The image also just shows a link. The real power is in clicking on the link regardless of location.

Demonstrates how to reference a local image

screenshot of the sample

Row Actions

 

screenshot of the sample

Create a button to conditionally launch a Flow for the selected item

screenshot of the sample

Multi-Choice forEach

 

screenshot of the sample

Multi-Choice Icons

screenshot of the sample

 

Multi-Person Facepile

screenshot of the sample

User Profile Picture sizes

Key Size
S 48×48
M 72×72
L 300x?*

 

Determine Tolerance Comparison using abs()

screenshot of the sample

Icon Progress Bar

 

screenshot of the sample

 

Displays a customizable Bing Map image for a given location in a Multi-Line of Text Field

 

screenshot of the sample

Text Contains

 

screenshot of the sample

Text StartsWith Calling Codes

 

screenshot of the sample

File Thumbnails

screenshot of the sample

Publishing Status

Before screenshot of the sample before formatting Afterscreenshot of the sample after formatting

Display Location Address Details

Summary

Location columns provide several properties that can be accessed to provide more information to users. This sample pulls out sub properties to turn the standard Display Name only to a full address and provides a link to Bing Maps for a given location.

screenshot of the sample

Multi-Person Teams Chat Link

Summary

This sample demonstrates creating a deep link to a Microsoft Teams chat. This format works both within Microsoft Teams and within SharePoint Online.

screenshot of the sample in Microsoft Teams

screenshot of the sample in a Modern List View

Custom hover card on Lists

Summary

The following image shows a list with a custom hover added to a List:

On hover – Metadata on the column “Status” is made available via column formatting

screenshot of the sample

 

Date Difference

Summary

This sample demonstrates calculating the difference between 2 dates. In this sample the age in years is calculated based on the date of birth and the date of death. This format could easily be adjusted to calculate a different unit of time (months, days, hours, minutes, etc.) by adjusting the multiplier.

screenshot

Icon Overlays

Summary

You can UI Fabric Icons within your column and view formats. This sample demonstrates combining multiple icons by overlaying to create colorful icons that can indicate more information than a single icon can.

Overlays are done by using a parent element with a style -> position value of relative. Then we can have the child elements use a position value of absolute to precisely overlay the icons where we want them.

generic-icon-overlay.json

This sample demonstrates using a solid icon (HeartFill) to provide a colored background to our icon and overlaying a wireframe icon to create an outline. The icons are shown conditionally based on the value. Using this technique with the various Solid, Mask, and Fill icons available can create far more icons than are currently available and allows more precise control of the coloring.

screenshot of the sample

Number Gauge

Summary

This sample demonstrates combining a fixed SVG (gauge background) with a dynamic SVG (needle). It makes understanding number columns (percent) very intuitive.

screenshot

Wrap up

Again those samples are all available on PNP Github.

Which one are you using ? Which one you wish to see as Column formatting ?

18 thoughts on “SharePoint Online Column Formatting Options

Add yours

  1. Jeff was very helpful with giving me ideas and solutions (that I modified to fit my own needs) in solving an issue with a SharePoint list. He was very responsive to my questions and asked good questions in return to better understand what I was trying to accomplish. He was very helpful, as is his web site Office 365 Notes.

    Like

  2. This works fine. Only issue is if you have a calculated date column in the same library as the column you add formatting to the date format switches to the JSON Data and time and looks terrible, not sure if this is a feature or a bug?! Using JSON in any column sets JSON for all columns even if not code entered so some calculated columns get odd outputs. just to be aware of this.

    Like

      1. @jeffangama, I “tweaked” the mailto sample to just show icons for some internal links based on other column data (e.g., $Alias, $Role). In the process had “them” correct the source page on MS docs (https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting#add-an-action-button-to-a-field-advanced). The class for clickable actions (sp-field-quickActions) was missing the trailing “s”, so using the code “as-is” (pre-fix) would not render the icons in an a/href at all. Depending on my team’s needs, desire for pretty pictures, etc. we may incorporate other actions, etc. but still in look-see mode.

        Liked by 1 person

  3. Is there a way to format column based on duplicate values. I have a view that uses a Group By based on a column. What could be a best option to find the count and apply a a background color if count of group by is greater than 1.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: