Replies: 3 comments
|
I think you're looking for the |
0 replies
|
@astahmer Thanks for responding. Can we set |
0 replies
|
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 ! |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
srcfile so the consumer (App) project can eliminate and purge unused styles at build time.Suppose we're building
Buttoncomponent. It has 5 colors and 3 variants (filled,outlined,text),For
outlinedvariants:border-colorbased on the current color of the componentFor
filledvariants:background-colorbased on the current color of the component
We used to haveOur Previous Solution
emotionso we could apply style conditionally. We had developed aGenerateBorderColorandGenerateBackgroundColorutilities and used them to set corresponding styles based on passed colors.here is the
generateButtonBackgroundColorfunction (Please look at thedefaultcase 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)
compoundVariantsstyled 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
All reactions