LogoLogo
HomepageYouTube ChannelInstall from the AppExchange
  • Home
  • Dynamic Components
  • Flow Components
  • Experience Components
  • Projects
  • 👋Welcome
  • Getting Started
    • Product Tour
    • Quickstart Tutorial
    • Avonni Components App
      • Accessing the App
      • Folders
      • Templates
      • Version management
    • Understanding The Essentials
      • Component Builder
      • Component Visibility
      • Target Page Object
      • Using Variables and Component Data
      • Publishing your Dynamic Components
      • Dynamic vs. Flow Components
    • AppExchange Listing Page
    • Installation & Licenses Management
  • Tutorials
    • Projects
    • Components
      • Calendar
        • How to Create Events Quickly by Dragging
        • How to Add an Edit Action to Calendar Events
        • How to Add a New Event Button to the Calendar Header
        • How to Customize the Right-Click Menu
        • How to Reschedule Events with Drag and Drop
      • Columns
        • Creating a Responsive 3-Column Layout
      • Data Table
        • How to customize Data Table style
        • How to make a field editable
        • How to add clickable buttons
        • How to color-code badges
        • How to export data
        • How to configure search
        • How to set columns visibility
        • How to Conditionally Color Data Table Cells
      • Kanban
        • Saving Changes on Drag-and-Drop
      • List
      • Metric
      • Record Detail
        • Saving Changes
    • Interactions
      • How to create an interaction to navigate to an object page
      • How to create an interaction to navigate to a record page
      • How to Pass Multiple Selected Records from a Dynamic Component to a Screen Flow
    • Reactive Components
      • Reactive Map and Data Table
      • Master-Detail Relationship with Data Tables
      • Vertical Tabs with Reactive Data Table
    • Style
      • How do you add space or a break between sections or fields?
    • Tips and Tricks
      • Using the Dynamic Component component
  • Component Builder
    • Overview
    • Configuring Components
      • Properties
      • Fields
      • Style
    • Data & Interactions
      • Data Sources
        • Manual
        • Picklist
      • Resources
        • Constant
        • Formula
        • Nested Queries
        • Query
        • Variable
      • Interactions
        • CRUD from Record Variable
        • Download
        • Execute Flow
        • Navigate
        • On Load
        • Open Alert Modal
        • Open Confirm
        • Open Dynamic Component Dialog
        • Open Dynamic Component Panel
        • Open Flow Panel
        • Open Flow Dialog
        • Show Toast
    • Advanced Features
      • Copy and Paste
      • Debug Panel
      • Keyboard Shortcut
      • Undo / Redo
  • Components
    • Explore All Components
    • Accordion
    • Alert
    • Audio Player
    • Avatar
    • Avatar Group
    • Badge
    • Barcode
    • Blockquote
    • Button
    • Button Group
    • Button Icon
    • Button Menu
    • Button Stateful
    • Calendar
    • Camera 🆕
    • Card
    • Carousel
    • Chart
    • Checkbox
    • Checkbox Button
    • Chip Container
    • Color Picker
    • Columns
    • Combobox
    • Container
    • Counter
    • Data LWC Container
    • Data Table
    • Date Picker
    • Date
    • Date Range
    • Dual Listbox
    • Dynamic Component
    • File Upload
    • Flow
    • Formatted Address
    • Formatted Name
    • Formatted Value
    • Header
    • Icon
    • Icon Picker
    • Illustration
    • Image
    • Input Color
    • Input Date
    • Input Pen (Signature)
    • Input Text
    • Kanban
    • List
    • LWC Container
    • Map
    • Media Object
    • Metric
    • PDF Viewer
    • Pivot Table
    • Progress Bar
    • Progress Circle
    • Progress Indicator
    • Rating
    • Record Detail
    • Relationship Graph
    • Scope Notification
    • Section
    • Separator
    • Slider
    • Status
    • Tabbed Container
    • Tabs
    • Text
    • Text Area
    • Timeline
    • Toggle
    • Tree
    • Vertical Visual Picker
    • Video Player
    • Visual Picker
    • Visual Picker Link
  • Help
    • Contact Support
    • Security
    • Performance Guide
    • Deployment Process
    • Release Notes
    • Report Bugs
Powered by GitBook
LogoLogo

Company

  • About Us
  • Pricing

Policies

  • Privacy Policy
  • Terms of Service
On this page
  • Core Concept: The SLDS Cell Class Attribute
  • Method 1: Applying Static Styling (Same Style for All Rows)
  • Method 2: Conditional Styling (Style Based on Row Data)
  • Practical SLDS Classes for Cell Styling
  • Conclusion

Was this helpful?

  1. Tutorials
  2. Components
  3. Data Table

How to Conditionally Color Data Table Cells

Last updated 1 day ago

Was this helpful?

This tutorial explains how to customize the appearance of cells within an Avonni Data Table in Avonni Dynamic Components. You'll learn how to apply a consistent style to an entire column or implement powerful conditional styling where a cell's appearance (like its background color) changes based on the data in its row.

Core Concept: The SLDS Cell Class Attribute

The key to all cell styling in the Avonni Data Table is the SLDS Cell Class attribute. It's found within the configuration settings for each column.

  1. Select your Avonni Data Table component on the canvas.

  2. In the Properties Panel, go to the Columns section.

  3. Select the specific column you want to style.

  4. Navigate to the Cell Attributes settings for that column.

  5. Locate the SLDS Cell Class input field.

This field accepts standard SLDS (Salesforce Lightning Design System) class names, allowing you to control text color, background color, font weight, and more.


Method 1: Applying Static Styling (Same Style for All Rows)

Use this simple method when you want every cell in a specific column to have the same, unchanging style.

Steps:

  1. Navigate to the SLDS Cell Class attribute for your desired column (as described above).

  2. Directly type the SLDS class names you want to apply into the field. Separate multiple classes with a space.

  • Example 1: To make all text in the column green and bold, enter: slds-text-color_success slds-font-weight_bold

  • Example 2: To give all cells a light grey background and capitalize the text, enter: slds-theme_shade slds-text-title_caps

The styling will be applied consistently to all rows in that column.


Method 2: Conditional Styling (Style Based on Row Data)

This is a more powerful technique where a cell's appearance changes dynamically based on the data within its row. This is perfect for visually indicating status, priority, or risk levels.

The easiest and most maintainable way to achieve this is by mapping the SLDS Cell Class attribute directly to a Salesforce Formula Field.

Step 2.1: Create a Salesforce Formula Field

First, create a formula field on the Salesforce object that your data table displays (e.g., on the Opportunity, Case, or Account object). This formula will determine which SLDS classes to use based on other fields in the record.

  1. In Salesforce Setup, navigate to the object you are using (e.g., Opportunity).

  2. Create a new Formula Field.

  3. Set the Formula Return Type to Text.

  4. In the formula editor, use logic (like a CASE() or IF() statement) to output the desired SLDS class string.

Example Formula on an Opportunity object (Field Name: StageStyle):

CASE(
  StageName,
  "Closed Won", "slds-theme_shade slds-theme_success",
  "Closed Lost", "slds-theme_shade slds-theme_error slds-text-color_inverse",
  "Needs Analysis", "slds-theme_shade slds-theme_warning",
  "Prospecting", "slds-theme_shade",
  ""
)

This formula checks the StageName field and returns a different set of SLDS classes for each stage, resulting in different background/text colors.

  1. Save your new formula field.

Step 2.2: Configure the Data Table

  1. Update Your Query: In your Dynamic Component, go to the Avonni Query Data Source for your Data Table. Crucially, make sure to add your new Salesforce formula field (e.g., StageStyle__c) to the list of queried fields.

  2. Map the Column: In the Data Table's properties, go to the Columns section and select the column you want to style (e.g., the StageName column).

  3. Bind the SLDS Cell Class:

    • Navigate to the Cell Attributes for that column.

    • Find the SLDS Cell Class property.

    • Toggle the field name option.

    • Select your new Salesforce formula field from the list of available fields (e.g., StageStyle__c).

Result: When the component loads, the Data Table will evaluate the StageStyle__c formula field for each row. It will then apply the corresponding SLDS classes, automatically coloring each cell based on the Opportunity's stage.


Practical SLDS Classes for Cell Styling

Here are some standard SLDS classes you can use in your formulas or for static styling (combine them with spaces):

  • Backgrounds: slds-theme_success (green), slds-theme_error (red), slds-theme_warning (yellow), slds-theme_info (blue), slds-theme_shade (light grey - a good base).

  • Text Color: slds-text-color_success (green), slds-text-color_error (red), slds-text-color_warning (dark yellow), slds-text-color_inverse (white - for dark backgrounds).

  • Text Style: slds-text-title_caps (ALL CAPS), slds-font-weight_bold (bold), slds-font-style_italic (italic).

Conclusion

The SLDS Cell Class attribute provides a flexible way to enhance data presentation in your Avonni Data Table. You can apply simple static styling or, more powerfully, use Salesforce Formula Fields to implement data-driven conditional formatting, effectively highlighting key information for your users