Share via

How do I format a row in a list with conditional formatting

Keith Sublett 0 Reputation points
Feb 25, 2025, 4:47 PM

I am creating a list in a SharePoint Teams Channel with a Yes/No column labeled "Completed." I want to format the rows with "Yes" in the column, with strikethrough text.

I have never used JSON before, but the articles I've read seem to suggest this.

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,367 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Yanli Jiang - MSFT 29,686 Reputation points Microsoft Vendor
    Feb 26, 2025, 9:18 AM

    Hi @Keith Sublett ,

    Good days. Welcome to Q&A forum!

    In SharePoint’s modern list view, Yes/No columns are treated as booleans (true/false), so you can test for true.

    Please follow these steps:

    1. Open your list.
    2. Click the column header (e.g., Title) and choose Column settings > Format this column.
    3. Select Advanced mode.
    4. Paste the following JSON:
    JSON
    
    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "style": {
        "text-decoration": "=if([$Completed] == true, 'line-through', 'none')",
        "padding":"0 45px",
        "font-size":"20px"
      },
      "txtContent": "@currentField"
    }
    

    And the result:

    User's image

    Hope this information helps.

    Please do let us know if you have any further queries.

    Kindly consider accepting the answer if the information provided is helpful. This can assist other community members in resolving similar issues.


  2. Yanli Jiang - MSFT 29,686 Reputation points Microsoft Vendor
    Feb 27, 2025, 7:02 AM

    Hi @Keith Sublett ,

    Ok, I got it. In that case, I suggest you use the built-in conditional formatting for rows.

    Please follow these steps:

    1. Open your list.
    2. Click All Items view and choose Format current view.
    3. Click Manage rules in Conditional formatting.
    4. Click Add rule to enter the following page: 02271
    5. Fill in the condition If Completed is equal to true, then click the button in the red box in the above picture, select More styles, and enter the following page: 02272 Set according to your needs, and then click Save.

    Hope this information helps.

    Please do let us know if you have any further queries.

    Kindly consider accepting the answer if the information provided is helpful. This can assist other community members in resolving similar issues.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.