Forum Discussion

Dc111222's avatar
Dc111222
Copper Contributor
May 21, 2021

Sharepoint list how to wrap text in gallery view

Hi. Can anyone tell me how to format text when viewing in gallery mode so that the text wraps within the tile? Guessing this is probably some JSON coding?
  • Dc111222 You are right. You have to customize the card designer JSON for gallery view & add style to the element where you want to wrap the text.

     

    You can use the styles like word-wrap in JSON. Full list of supported styles is given at: SharePoint JSON Formatting - style 

     

    You can find detailed step about how to customize the card design JSON for gallery view in below post:

    Change the width of a card in Gallery view of a List  


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

    • JeffThiel's avatar
      JeffThiel
      Copper Contributor

       I inadvertently posted this question on another board. I'm not a programmer and just getting introduced to JSON via my duties in SharePoint.  I can get the following to work on Kudos field via column formatting.  I can see this in list view. How do I get same word wrap formatting added to gallery tile view JSON?  When I add the following to JSON in gallery view, the text field disappears.  Kudos is single line text field.   I'll be able to adjust the tile height/width but stuck on word wrap. Thank you in advance. 

       

      {"elmType": "div", "style":{ "white-space":"wrap" }, "txtContent": "@Kudos" }

       

      Where does the above json go in gallery view JSON below?

      {
      "elmType": "div",
      "attributes": {
      "class": "sp-card-displayColumnContainer"
      },
      "children": [
      {
      "elmType": "p",
      "attributes": {
      "class": "ms-fontColor-neutralSecondary sp-card-label"
      },
      "txtContent": "[!Kudos.DisplayName]"
      },
      {
      "elmType": "p",
      "attributes": {
      "title": "[$Kudos]",
      "class": "ms-fontColor-neutralPrimary sp-card-content sp-card-highlightedContent"
      },
      "txtContent": "=if ([$Kudos] == '', '–', [$Kudos])"
      }
      ]
      }

       

       

       

      ganeshsanap

      • ganeshsanap's avatar
        ganeshsanap
        MVP

        JeffThiel Try using below JSON:

         

        {
          "elmType": "div",
          "attributes": {
            "class": "sp-card-displayColumnContainer"
          },
          "children": [
            {
              "elmType": "p",
              "attributes": {
                "class": "ms-fontColor-neutralSecondary sp-card-label"
              },
              "txtContent": "[!Kudos.DisplayName]"
            },
            {
              "elmType": "p",
              "attributes": {
                "title": "[$Kudos]",
                "class": "ms-fontColor-neutralPrimary sp-card-content sp-card-highlightedContent"
              },
              "txtContent": "=if ([$Kudos] == '', '–', [$Kudos])",
              "style": {
                "white-space": "wrap"
              }
            }
          ]
        }

         


        Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Resources