Pricing Blog

Switch for button color

  • matt_apollodev-1415594988183748649

    Matthieu B.

    3 days ago

    TL;DR : switch logic in nordcraft ?

    I'm trying to say this :
    - if my attribute = 'black' -> then define a specific style variable,
    - if 'outlined' -> then output a different color
    - if 'warning' -> then ..
    - if 'error' -> then ...

    I can do it with if/else blocs but it looks complex, and I like to make things look simple 😇

    A simple switch would have been simple, but it seems that there isn't.

    How do you deel with this use case ?
  • whitep4nth3r-1415604868944629871

    salma

    2 days ago

    Send a screenshot of your formulas, there may be a way to simplify using "Default To" but this currently sounds like the way to do it in the formula editor.
  • filip_dajkovic-1415616416178241546

    Filip Dajkovic

    2 days ago

    Using Objects with Get formula can work as a switch:
    1415616415838507008-CleanShot_2025-09-11_at_10.32.322x.png
    🔥1
  • martinf4630-1415647199446044703

    MartinF

    2 days ago

    I use what Filip suggested a bunch, you can also use style variables/classes with formula controlling them conditionally. E.g. state = warning then element will have class warning and then style as you want.
    👍1