Back to column formats
Column formattingSharePoint Online

Right-Aligned Content

This sample shows how to right-align your content, while preserving the number or date format set using the SharePoint / Lists UI. Numbers and dates should typically be presented as right-aligned, for improved readability.

Right-Aligned Content formatting preview
Sample preview · View original image

Copy. Apply. Make it yours.

Get this format

1 definition

Review the requirements below, then paste this JSON into the matching formatting panel. Show me where.

Use your list's internal column names and replace any tenant-specific URLs or flow IDs. Formatting is presentation, not a way to secure data.

Column formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "display": "table",
    "width": "100%"
  },
  "children": [
    {
      "elmType": "div",
      "txtContent": "@currentField.displayValue",
      "style": {
        "display": "table-cell",
        "text-align": "right",
        "vertical-align": "middle"
      }
    }
  ]
}

From the contributor

How to use this sample

Summary

This sample shows how to right-align your content, while preserving the number or date format set using the SharePoint / Lists UI. Numbers and dates should typically be presented as right-aligned, for improved readability.

screenshot of the sample

Most existing json formatting samples or examples for this requirement (blog, forum posts, etc.) lose the number or date format, making them impractical to use as the result is hard to read. Some examples try to remedy this with complex string manipulation to reformat the values, which can be fragile. With the recent addition of .displayValue none of that is necessary!

Simply set the desired formatting using the SharePoint / Lists UI, and this sample will honor those settings while aligning them to the right.

View requirements

  • This format can be applied to any column type. It is best suited to numeric/currency or date columns.

Sample

Solution Author(s)
generic-right-align.json Mike Honey

Version history

Version Date Comments
1.0 February 13, 2021 Initial release

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.


Additional notes

None