Skip to main content
See also: Styles | Columns | Column Groups

How Formatters Work

Formatters provide conditional cell styling based on runtime data. Each formatter is a named array of rules. When a cell renders, Powersheet evaluates each rule’s expression against the current cell context. If the expression returns true, the associated style is applied to that cell.
diagram

Formatter Definition

YAML Structure

The formatters section is a root-level key in the sheet configuration, alongside columns, styles, sources, views, columnGroups, renderers, and sortBy.

Expression Context

Every formatter expression has access to the context object. This is the same context available to renderers and dynamic value expressions.

Expression Types

Formatter expressions support two notation types: Simple boolean expression (recommended):
Unlike other dynamic expressions, a formatter expression is a bare boolean expression (e.g., value > 100). It does not use the () => prefix; it is evaluated as a direct boolean condition.
Inline style object (the style property supports the same CSS properties as Styles):
Complex JavaScript expressions in formatters are not recommended. Keep expressions simple — use straightforward property comparisons and boolean logic. Complex multi-line expressions may cause rendering issues.

Referencing Formatters from Columns

Columns reference formatters by name using the formatter property. The value must match a key defined in the formatters section.
The formatter column property also accepts an array of formatter names for composing multiple formatting rule sets:
The formatter value on a column must exactly match a key defined in the formatters section. A mismatched name results in no formatting being applied with no error message.

Unconditional Formatters

A formatter with expression: 'true' always applies its style. This is useful for marking columns as visually distinct without conditions.

Read-Only Column Styling

The isReadOnly column property and formatters serve different purposes. Use isReadOnly: true on a column to prevent editing regardless of formatting. Use a formatter with style: readOnly for visual read-only indication. The isReadOnly value may be overwritten by user permissions or global document configuration.

Bold Title Styling

Conditional Formatters

Conditional formatters evaluate entity properties at render time and apply styles only when conditions are met.

Status-Based Formatting

Numeric Threshold Formatting

Null / Empty Value Formatting

Multiple Rules per Formatter

A formatter can contain multiple rules. All rules are evaluated in order, and each matching rule applies its style. When multiple rules match, the later rule’s style properties override earlier ones for the same CSS property.
In this example, a high-priority blocked item receives both the red style (background and text color) and the line-through text decoration.

Predefined Styles for Formatters

Formatters reference styles by name. Powersheet provides 20 built-in styles that can be used directly without defining a custom styles section. See Styles for the full list. Commonly used predefined styles with formatters:
When a formatter references a style name, Powersheet first checks custom styles defined in the styles section, then falls back to built-in styles. A custom style with the same name as a built-in style overrides the built-in.

Row-Level Formatting

Formatters are typically applied at the column level. When a formatter is referenced from a column that spans the full row (such as an outline number column), the visual effect appears to apply to the entire row.

Interaction with Views

Views can override column properties including the formatter reference. A view can assign a different formatter to a column or remove formatting entirely.
The Base View is the state defined by the root columns section. Views extend the Base View by overriding specific column properties. If no views are defined or no default view is specified, the Base View is applied automatically.

Relationship Between Formatters, Styles, and Columns

diagram
The three sections work together in a clear chain:

Formatter Naming Conventions

Choose formatter names that describe their purpose. Common patterns in Powersheet configurations:

Complete YAML Example

A requirements traceability sheet configuration with formatters for severity, status, and read-only columns using the standard RTM entity hierarchy (UserNeed > SystemRequirement > DesignRequirement > Hazard > RiskControl):

Best Practices

Use predefined styles whenever possible rather than defining custom inline styles. The 20 built-in styles cover most color coding needs. Keep expressions simple. Use straightforward property comparisons (==, <=, >, !) and avoid multi-line or deeply nested JavaScript. Name formatters descriptively. A name like severityFormat is clearer than fmt1 when reviewing configuration. Separate concerns. Define styles in the styles section and reference them from formatters rather than using inline style objects. This promotes reuse across multiple formatters. Order rules intentionally. When multiple rules can match, later rules override earlier ones for the same CSS property. Place higher-priority styles last. ⚠️ Avoid complex expressions. Simple boolean expressions are recommended. Complex JavaScript in formatter expressions may cause unexpected behavior. ⚠️ Do not confuse formatter and render. The formatter property controls cell styling (colors, fonts). The render property controls cell content rendering (custom HTML output). See Render Property.

Conditional Formatting Chain

The full conditional formatting system connects three configuration sections in a chain: the column references a formatter by name, the formatter evaluates expressions and references a style, and the style defines the visual properties.
diagram

Style Properties Quick Reference

When defining custom styles for use with formatters, these are the supported CSS properties:

All Predefined Styles

All 20 predefined styles can be used in formatter rules without defining them in the styles section:

Decision Matrix: Choosing the Right Approach

  • Styles — Named style definitions referenced by formatters
  • Columns — Column configuration including the formatter property
  • Render Property — Custom content rendering (distinct from formatting)
  • Dynamic Value Expressions — Full reference on the context object and expression syntax
  • Views — View-level overrides for column formatting
  • Column Groups — Visual grouping with groupStyle and headerStyle
  • Keyboard Shortcuts — Keyboard navigation in the sheet

Last modified on July 10, 2026