Conditional css deck

  • 1
  • Question
  • Updated 5 months ago
  • Answered
Hi,
can I change card background color base on value field of the single record?

Thank you in advance
Photo of Andrea

Andrea

  • 460 Points 250 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
Hey Andrea,

Can you provide a little more clarity into what you'd like to do? Are you wanting the entire background of a deck to be the same color for only one "card" in the deck? Or are you wanting a particular value within the decks to be a certain color - like if the record is "yes" it'll be green but if it is "no" then it'll be red? Pictures are abundantly helpful... 

Thanks!
Photo of Andrea

Andrea

  • 460 Points 250 badge 2x thumb

Hi Stephen,
thank you for the reply,
each card in the deck should have a different color based on a value from a record field.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
bump
Photo of John Dahlberg

John Dahlberg, Champion

  • 2,442 Points 2k badge 2x thumb
My favorite approach to this is to use a salesforce formula field to calculate the desired color or a classname that references a CSS definition, then use that field in a merge in a template field, the css reference on a component or elsewhere.  This centralizes the color selection logic to the data source so it's consistent throughout the UI and doesn't require any scripting.  Note that SKUID will generally merge values on component definitions in the page editor and if they are tied to a model you can use the basic field name (like in the CSS setting).

Here's an example of the formula used to drive the display of tasks in a deck:


This is the template used for the display in the deck:


Here's the display:




Here's a link to another post with more detail.
https://community.skuid.com/skuid/topics/color-picklist-value-based-on-status