0

I have a custom list with Title and Description.

I wish to display the list view as a gallery with only the Title in it. On hover over the title, it should display the description field covering the gallery item.

I plan to implement this with list view formatting. Any help would be appreciated.

1 Answer 1

0

You can achieve this using JSON view formatting. Below is basic JSON sample which will help you to get started with:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/tile-formatting.schema.json",
  "height": 53,
  "width": 254,
  "hideSelection": true,
  "fillHorizontally": true,
  "formatter": {
    "elmType": "div",
    "attributes": {
      "class": "sp-card-container"
    },
    "children": [
      {
        "elmType": "button",
        "attributes": {
          "class": "sp-card-defaultClickButton",
          "role": "presentation"
        },
        "customRowAction": {
          "action": "defaultClick"
        },
        "customCardProps": {
          "formatter": {
            "elmType": "div",
            "txtContent": "[$Description]",
            "style": {
              "padding": "20px"
            }
          },
          "openOnEvent": "hover",
          "directionalHint": "bottomCenter",
          "isBeakVisible": true,
          "beakStyle": {
            "backgroundColor": "white"
          }
        }
      },
      {
        "elmType": "div",
        "attributes": {
          "class": "ms-bgColor-white sp-css-borderColor-neutralLight sp-card-borderHighlight sp-card-subContainer"
        },
        "children": [
          {
            "elmType": "div",
            "attributes": {
              "class": "sp-card-lastTextColumnContainer"
            },
            "children": [
              {
                "elmType": "div",
                "attributes": {
                  "title": "[$Title]",
                  "class": "ms-fontColor-neutralPrimary sp-card-content sp-card-highlightedContent"
                },
                "txtContent": "=if ([$Title] == '', '–', [$Title])"
              }
            ]
          }
        ]
      }
    ]
  }
}

Output:

enter image description here

Documentation: Use view formatting to customize SharePoint

8
  • Is there a way to display the description card inside the title div container rather than a bubble? I was still able to hide the break indicator.
    – Ashish
    Sep 29, 2021 at 6:10
  • That will be difficult a bit. It will break when there is large description & title container is of small size. Yes, if you want you can hide the beak using JSON styling. Sep 29, 2021 at 6:14
  • I was able to bring the description inside the container. But this only gets highlighted when hovered over the title. How can I make this display over card hover. "txtContent": "[$Title]", "customCardProps": { "formatter": { "elmType": "div", "children": [ { "elmType": "div", "children": [],
    – Ashish
    Sep 29, 2021 at 6:21
  • Not sure how can I post the full JSON code. So posted a chunk of it.
    – Ashish
    Sep 29, 2021 at 6:21
  • I am adding the customCardProp to the title. Can I add that to the full card?
    – Ashish
    Sep 29, 2021 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.