How to Use Notion Formula style() Function for Conditional Color
🔍 WiseChecker

How to Use Notion Formula style() Function for Conditional Color

Notion formulas can do more than calculate numbers and combine text. The style() function adds visual formatting to formula output, including conditional color, bold, italic, and strikethrough. This feature lets you highlight overdue tasks, flag high-priority items, or color-code status fields automatically. This article explains how the style() function works, how to write conditional color formulas, and what common mistakes to avoid.

Key Takeaways: Using style() for Conditional Color in Notion

  • style() syntax: style(text, color, bold, italic, strikethrough) — each parameter is optional and must be a string or boolean.
  • Conditional color with if(): Use if(prop("Status") == "Done", style(prop("Name"), "green"), style(prop("Name"), "red")) to change color based on a property value.
  • Supported colors: “default”, “gray”, “brown”, “orange”, “yellow”, “green”, “blue”, “purple”, “pink”, “red” — use lowercase strings only.

ADVERTISEMENT

How the Notion style() Function Works

The style() function returns a text string with visual formatting applied. It does not change the underlying data. The function accepts up to five arguments. The first argument is the text or formula result you want to format. The second argument is the color. The third is bold, the fourth is italic, and the fifth is strikethrough. Each formatting parameter is optional. If you omit a parameter, the function applies no formatting for that attribute.

The color argument must be a lowercase string from this list: "default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red". The bold, italic, and strikethrough arguments must be boolean values: true or false. You can combine multiple formatting types in one style() call, for example style(prop("Name"), "red", true, false, false) makes the name red and bold.

The style() function works inside any formula property. It can wrap a simple property reference, a concatenation, or a conditional if() result. The formatted output appears in the database view but not in exported data or API responses. This limitation is important if you rely on exports for reporting.

Writing a Conditional Color Formula with style()

Conditional color means the formula applies a different color based on a condition. The most common pattern uses if() to check a property value and return a style() call with the matching color. Below is a step-by-step guide to create a formula that colors a task name based on its status.

  1. Create a formula property
    Open your database. Click the + icon on the rightmost column header. Select Formula from the property type list. Name the property, for example “Colored Name”.
  2. Write the conditional formula
    In the formula editor, enter this code:
    if(prop("Status") == "Done", style(prop("Name"), "green"), if(prop("Status") == "In Progress", style(prop("Name"), "blue"), style(prop("Name"), "red")))
    This formula checks the Status property. If Status equals “Done”, it shows the name in green. If Status equals “In Progress”, it shows the name in blue. Otherwise, it shows the name in red.
  3. Test with sample data
    Add a few rows with different Status values. The formula column should display each name in the matching color. If a color does not appear, check for typos in the color string. Notion does not show an error for invalid color strings — it simply applies no color.
  4. Add bold or italic formatting
    To make the name bold when the status is “Done”, modify the first style() call:
    style(prop("Name"), "green", true)
    The third argument true enables bold. You can add false for italic and strikethrough if you do not need them.
  5. Use style() with a date comparison
    To highlight overdue tasks, write:
    if(prop("Due Date") < now() and prop("Status") != "Done", style(prop("Name"), "red", true), style(prop("Name"), "default"))
    This formula makes the name red and bold when the due date is in the past and the task is not marked Done. Otherwise, it applies no special color.

ADVERTISEMENT

Common Mistakes and Limitations with style()

style() does not work on rollup or formula properties

The style() function can only format text that originates from a text, select, multi-select, or title property. If you try to wrap a rollup or another formula property, the formatting is ignored. To apply conditional color to a rollup value, create a formula property that references the rollup and apply style() there.

Color string must be lowercase and spelled exactly

Notion does not validate the color argument. If you write "Green" with a capital G, the function returns the text without color. Always use lowercase: "green". The same applies to "red", "blue", and all other supported colors.

Formatted text does not appear in exports or API

When you export a database to CSV, Markdown, or PDF, the style() formatting is stripped. The exported text shows the raw string without color, bold, italic, or strikethrough. If you need formatted output in a report, consider using a third-party tool that reads the Notion API and applies its own formatting.

Nesting style() inside concat() may cause unexpected results

When you concatenate multiple style() calls with concat(), each segment retains its own formatting. For example, concat(style("High", "red"), " - ", style(prop("Name"), "blue")) shows "High" in red and the name in blue. However, if you concatenate a style() result with a plain string, the plain string inherits no formatting. This behavior is intentional but can be confusing when building complex formulas.

style() Conditional Color: Formula Examples Compared

Use Case Formula Result
Single condition if(prop("Priority") == "High", style(prop("Name"), "red"), style(prop("Name"), "default")) Name is red if Priority is High, otherwise no color
Multiple conditions if(prop("Status") == "Done", style(prop("Name"), "green", true), if(prop("Status") == "Blocked", style(prop("Name"), "red", true), style(prop("Name"), "default"))) Name is green and bold if Done, red and bold if Blocked, no formatting otherwise
Date-based if(prop("Due Date") < now(), style(prop("Name"), "red"), style(prop("Name"), "default")) Name is red if the due date is in the past
Checkbox true if(prop("Done"), style(prop("Name"), "gray", false, true), style(prop("Name"), "default")) Name is gray and italic if Done checkbox is checked

The table above shows four common patterns. Copy the formula for your use case and adjust the property names to match your database. Remember that style() returns a text value, so you cannot use it in number or date formulas.

Now you can use the style() function to add conditional color to any Notion database. Start by applying a simple two-color rule for a status field. Then extend the formula to include bold or italic for emphasis. For advanced use, combine style() with now() to create automatic deadline alerts. Because style() does not affect the underlying data, you can safely experiment without breaking your existing formulas.

ADVERTISEMENT