Forum Discussion
Sharepoint list how to wrap text in gallery view
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.
ganeshsanap Thank you very much for your reply. Unfortunately, I'm unable to get the text in field to wrap in gallery view. JSON below directly from gallery view... I can see word wrap in list field but not when in gallery view. Afraid i'm missing something simple here. Even if I increase height/width of card Kudos text field does not wrap. Please help when you get a moment. And thank you.
- uttam27Aug 19, 2022Copper Contributor
please try removing the below line:
"class": "ms-fontColor-neutralPrimary sp-card-content sp-card-highlightedContent"
- MarianLeinNetlutionAug 22, 2022Copper Contributor
uttam27 thanks for the hint - Unfortunately all this does, is to take the bold typeface from the header, where this "class" attribute is set.
As a reference, here's the relevant <div> from my JSON formatting - The incorrect breaks are happening in the "Beschreibung".
{ "elmType": "div", "attributes": { "class": "sp-card-displayColumnContainer" }, "children": [ { "elmType": "p", "attributes": { "class": "ms-fontColor-neutralSecondary sp-card-label" }, "txtContent": "Projekt:" }, { "elmType": "p", "style": { "text-align": "justify", "height": "150px", "white-space": "break-word" }, "attributes": { "title": "[$Beschreibung]", "class": "ms-fontColor-neutralPrimary " }, "txtContent": "=if ([$Beschreibung] == '', '–', [$Beschreibung])" } ] }- uttam27Aug 22, 2022Copper Contributor
Please try changing the line 19 from:
"white-space": "break-word"to:
"word-break": "keep-all"My apologies, I am also not expert in this, but this is something I found that helped me recently.
- MarianLeinNetlutionApr 21, 2022Copper Contributor
JeffThiel Have you ever gotten this to work? I'm stuck at the same thing here.
- JeffThielApr 21, 2022Copper Contributor
No, unfortunately I did not.