Replies: 3 comments
-
I think you're looking for the |
Beta Was this translation helpful? Give feedback.
-
@astahmer Thanks for responding. Can we set |
Beta Was this translation helpful? Give feedback.
-
yes you can ! the colors palette values are treated just like any other color token from your panda.config theme I'm on phone so I can't really provide an example, you should probably ask for some in the Panda discord, there's a ask-ai channel that should be pretty helpful here ! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
There is a need to add conditional styling (Or combinational style generation) to PandaCSS.
Problem Statement/Justification
We're refactoring a UI Library that is built by Emotion using Panda. We're shipping
src
file so the consumer (App) project can eliminate and purge unused styles at build time.Suppose we're building
Button
component. It has 5 colors and 3 variants (filled
,outlined
,text
),For
outlined
variants:border-color
based on the current color of the componentFor
filled
variants:background-color
based on the current color of the component
We used to haveOur Previous Solution
emotion
so we could apply style conditionally. We had developed aGenerateBorderColor
andGenerateBackgroundColor
utilities and used them to set corresponding styles based on passed colors.here is the
generateButtonBackgroundColor
function (Please look at thedefault
case where we're selecting color dynamically):There's a need to have such function in PandaCSS as well, otherwise we need to write 15 (3 variants * 5 colors)
compoundVariants
styled to handle such a simple styling.Please correct me if there is a right way to handle this requirement already.
Proposed Solution or API
Since PandaCSS API has so many differences from Emotion or Styled Component solutions, I don't have a precise or exact solution to this challenge.
think referencing the theme values is the key solution to this problem. Something like this API:
And then we can create recipe like this:
Alternatives
No response
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions