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’sexpression against the current cell context. If the expression returns true, the associated style is applied to that cell.
Formatter Definition
YAML Structure
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 thecontext 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.Referencing Formatters from Columns
Columns reference formatters by name using theformatter property. The value must match a key defined in the formatters section.
formatter column property also accepts an array of formatter names for composing multiple formatting rule sets:
Unconditional Formatters
A formatter withexpression: 'true' always applies its style. This is useful for marking columns as visually distinct without conditions.
Read-Only Column Styling
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.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 customstyles 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 theformatter reference. A view can assign a different formatter to a column or remove formatting entirely.
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
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.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 thestyles section:
Decision Matrix: Choosing the Right Approach
Related Pages
- Styles — Named style definitions referenced by formatters
- Columns — Column configuration including the
formatterproperty - Render Property — Custom content rendering (distinct from formatting)
- Dynamic Value Expressions — Full reference on the
contextobject and expression syntax - Views — View-level overrides for column formatting
- Column Groups — Visual grouping with
groupStyleandheaderStyle - Keyboard Shortcuts — Keyboard navigation in the sheet