Sharepoint online list specify column width and row height with json

cpatenta picture cpatenta · Nov 25, 2019 · Viewed 7.5k times · Source

I am trying to format a SharePoint Online modern list using json and I couldn't find a way to specify a custom column width and row height. So far it looks like this and users have to manually adjust column width.

enter image description here

My json code is this:

Also, I couldn't find a way to make the list more compact. The default row height is too high.

How can I specify column width and row height?

I am new to SharePoint so any help will be appreciated. Thank you!

Answer

Michael Han_MSFT picture Michael Han_MSFT · Nov 26, 2019

To specify the column width and row height, you need to add the property "width" and "height" in your json code.

For exmaple:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
     "min-height":"1em",
    "height": "1em",
    "width": "100px"
  }
}

Please refer to this article for more: https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting